go/src/flag
Rob Pike 2d741947d8 flag: test IsBoolFlag when creating the usage message
Although I can't think of any reason to do this, it is possible for
a user-defined flag to implement IsBoolFlag but return "false".
This is nuts because checking the interface is satisfied should
obviously be sufficient, but the documentation kinda implies it's
not. And if you try this, you'll discover that the usage message
ignores the return value even though the rest of the package plays
nice. Bother.

So we fix it, as the fix is trivial: call the method when creating
the usage message.

Fixes #53473

Change-Id: I1ac80a876ad5626eebfc5ef6cb972cd3007afaad
Reviewed-on: https://go-review.googlesource.com/c/go/+/431102
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-09-19 21:54:35 +00:00
..
example_func_test.go flag: add Func 2020-09-16 17:13:14 +00:00
example_test.go
example_textvar_test.go flag: add TextVar function 2022-03-10 16:56:17 +00:00
example_value_test.go
export_test.go flag: make tests silent 2022-03-07 09:29:14 +00:00
flag.go flag: test IsBoolFlag when creating the usage message 2022-09-19 21:54:35 +00:00
flag_test.go flag: test IsBoolFlag when creating the usage message 2022-09-19 21:54:35 +00:00