pflag
pflag copied to clipboard
`SortFlags` not exported
The SortFlags
option mentioned in the README is not actually exported.
https://github.com/spf13/pflag/blob/d5e0c0615acee7028e1e2740a11102313be88de1/README.md?plain=1#L257
Instead CommandLine.SortFlags
is available.
# README.md
flags.BoolP("verbose", "v", false, "verbose output")
flags.String("coolflag", "yeaah", "it's really cool flag")
flags.Int("usefulflag", 777, "sometimes it's very useful")
-flags.SortFlags = false
+flags.CommandLine.SortFlags = false
flags.PrintDefaults()
The example code should be completed regarding how the "flags" variable is created.
The FlagSet.SortFlags
field is indeed exported. CommandLine
is a convenient FlagSet
exposed by the package.
Documentation bug, I'd say.