Valueless boolean parameters
ElPeque opened this issue · comments
Alejandro Martínez commented
@mtrias told me he liked boolean parameters to default to false, and asume true when sent with no value.
ex: ?someparam=4&booleanparam&someotherparam=6
in this case, the booleanparam is assumed as booleanparam=true
Preetam commented
For this, we'll have to define our own bool
type that satisfies the flag.Value
interface. The default one uses strconv.ParseBool
to parse the value string and it doesn't accept empty strings.
Preetam commented
Ignore my previous comment. I used this behavior instead: https://github.com/golang/go/blob/ab96371817545b1e6dc7d3679294256d2963ca4b/src/flag/flag.go#L100-L105