panic: reading /etc/services
Similar to #9 (closed), when the /etc/services file is not formatted correctly, this project will panic trying to parse the file.
History
Issue #9 (closed) was filed a year ago and linked to a non-English issue. Putting it through google translate reveals that in the users /etc/services file there is the following entry at the end:
privoxy 8118
Which does not follow the typical format of port/protocol (e.g. 21/tcp).
I am a maintainer of telegraf and recently received a similar issue, where the user had the same line in their /etc/services file.
Steps to reproduce
- Update
/etc/servicesfile to includeprivoxy 8118 - Create the following
main.go:
package main
import _ "modernc.org/libc"
func main() {}
- The following
go.mod:
module test
go 1.19
require modernc.org/libc v1.21.1
- Run
go run main.go - Remember to revert your change to
/etc/services
Logs
panic: runtime error: index out of range [1] with length 1
goroutine 1 [running]:
modernc.org/libc/honnef.co/go/netdb.init.0()
/go/pkg/mod/modernc.org/libc@v1.20.3/honnef.co/go/netdb/netdb.go:760 +0x4c8