spf13 / pflag

Drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags.
BSD 3-Clause "New" or "Revised" License
2.43k stars 348 forks source link

Misleading documentation for func StringToStringVar #397

Open fxierh opened 8 months ago

fxierh commented 8 months ago

Quoting from the documentation of func StringToStringVar:

The value of each argument will not try to be separated by comma.

However with the following program:

res := make(map[string]string)
flag.StringToStringVar(&res, "foo-flag", res, "foo-flag-usage")
flag.Parse()

go run ... --foo-flag "foo=bar,baz=quux" results in res = map[baz:quux foo:bar].

fxierh commented 8 months ago

I'm happy to submit a PR for this if needed.