]> Cypherpunks repositories - gostls13.git/commit
flag: return a consistent parse error if the flag value is invalid
authorRob Pike <r@golang.org>
Thu, 18 Oct 2018 23:48:53 +0000 (10:48 +1100)
committerRob Pike <r@golang.org>
Fri, 19 Oct 2018 03:48:38 +0000 (03:48 +0000)
commitae0c435877d3aacb9af5e706c40f9dddde5d3e67
tree8e567a5a8b72acf72de9b89bb17316ec8c5dd53f
parent95dda75bde8a6625b857b5f8013eed5e9563fd02
flag: return a consistent parse error if the flag value is invalid

Return a consistently formatted error string that reports either
a parse error or a range error.

Before:
invalid boolean value "3" for -debug: strconv.ParseBool: parsing "3": invalid syntax

After:
invalid boolean value "3" for -debug: parse error

Fixes #26822

Change-Id: I60992bf23da32a4c0cf32472a8af486a3c9674ad
Reviewed-on: https://go-review.googlesource.com/c/143257
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/flag/flag.go
src/flag/flag_test.go