forked from ogier/pflag
-
Notifications
You must be signed in to change notification settings - Fork 367
Open
Description
I have some flag definition code in cobra:
listCmd.Flags().IP("ip", nil, "--ip")And then i running this:
ip, err := flags.GetIP("ip")I got an error: invalid string being converted to IP address: <nil>
Same result with this definition:
listCmd.Flags().IP("ip", net.IP{}, "--ip")
In my logic, flag is optional, and i dont want to work with net.Parse("0.0.0.0") and string values.
Updated
nil as default value works thought IPVar, but wanna minimize package level variables for each command.
var ip net.IP
listCmd.Flags().IPVar(&ip, "ip", nil, "--ip")camsteffen