cobra
cobra copied to clipboard
how to set `nil` as default value in `BoolVar`?
I want to keep a variable as nil except explicitly set, but only true
or false
is allowed.
myCmd.Flags().BoolVar(&isMine, "isMine", nil, "")
In Go a bool cannot be nil but only true or false. If you’re thinking of the pointer you’re passing in, that cannot be nil as it must represent a location where cobra can write true or false