What version of Go are you using (go version)?
go version go1.9.7 linux/amd64 (but it affects basically all versions of go).
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (go env)?
GOHOSTARCH="amd64"
GOHOSTOS="linux"
What did you do?
Provide a non-numerical input for an integer flag yields the following error:
invalid value "donut" for flag -cpu-quota: strconv.ParseInt: parsing "donut": invalid syntax
What did you expect to see?
--cpuquota is expecting an integer
Something more user-friendly. Currently, the error message must be interpreted by the user and should guide users a bit more in a direction to solve the issue. See containers/buildah#673 as an example.
What did you see instead?
invalid value "donut" for flag -cpu-quota: strconv.ParseInt: parsing "donut": invalid syntax
Proposal
I want to suggest two options:
- Update the error messages (e.g., for integer flags https://golang.org/src/flag/flag.go?s=8120:8324#L912).
- Expose public error types (e.g.,
ErrInvalidValue and ErrInvalidBoolen) that can be used by users of the flag package (e.g., urfave/cli).
What version of Go are you using (
go version)?go version go1.9.7 linux/amd64 (but it affects basically all versions of go).
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env)?GOHOSTARCH="amd64"
GOHOSTOS="linux"
What did you do?
Provide a non-numerical input for an integer flag yields the following error:
What did you expect to see?
Something more user-friendly. Currently, the error message must be interpreted by the user and should guide users a bit more in a direction to solve the issue. See containers/buildah#673 as an example.
What did you see instead?
Proposal
I want to suggest two options:
ErrInvalidValueandErrInvalidBoolen) that can be used by users of theflagpackage (e.g.,urfave/cli).