Those two lines in your main function shadow your global variable declaration:
optQuit := getopt.BoolLong("quit", 0, "Help")
optRun := getopt.BoolLong("run", 'r', "Help")
If you only use them, to get a nice usage, why not create a usage function
yourself?
If you insist on using getopt
just to create a usage, do
_ = getopt.BoolLong("quit", 0, "Help")
_ = getopt.BoolLong("run", 'r', "Help")
instead.
You also need to call getopt.Parse()
before using *optHelp
.
The resulting message
Usage: test [-hr] [--quit] [parameters ...]
-h, --help Help
--quit Help
-r, --run Help
seems to be less than helpful. Why not just do
fmt.Printf(`
Usage: test
This program will start a daemon service, which you can use like this ...
`)
1
solved Receive from non-chan type *bool