--help should not panic & other argument-passing interrogations
drzraf opened this issue · 1 comments
drzraf commented
$ go version
go version go1.13.8 linux/amd64
$ cd ./go/bin/ && ./SystemdJournal2Gelf --help
panic: usage: SystemdJournal2Gelf SERVER:12201 [JOURNALCTL PARAMETERS]
goroutine 1 [running]:
main.main()
~/go/src/github.com/parse-nl/SystemdJournal2Gelf/SystemdJournal2Gelf.go:164 +0x64d
$ ./SystemdJournal2Gelf localhost:12201 -- --version
Failed to add match '--version': Invalid argument
# ^^ I would expect it to be passed to journald...
$ ./SystemdJournal2Gelf localhost:12201 --version
panic: could not parse journal output: invalid character 's' looking for beginning of value
# ^^ Why?
SjonHortensius commented
I see your point but all of these issues can be explained:
-
--help
panics because I usedpanic
instead offmt.Printf
+os.Exit
(I can fix this and you'd get the same error without the backtrace) I understand this might seem as if something went wrong -
-- --version
comes from journalctl: seejournalctl -- --version
. I see your point here as well as--
would normally be used as the option vs filter separator, but it currently isn't in this script -
--version
fails because this script expects JSON output.--version
outputs non-json data which it cannot parse