]> Cypherpunks repositories - gostls13.git/commit
flag: test IsBoolFlag when creating the usage message
authorRob Pike <r@golang.org>
Sun, 18 Sep 2022 12:05:00 +0000 (22:05 +1000)
committerRob Pike <r@golang.org>
Mon, 19 Sep 2022 21:54:35 +0000 (21:54 +0000)
commit2d741947d8931325576427b3699d1af20e7be7cf
tree4685c650f4a88f6b83e92b8deb89fafaf987014f
parentd31f85009cb81604c23e3e471fc4f7d62b9089ff
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>
src/flag/flag.go
src/flag/flag_test.go