]> Cypherpunks repositories - gostls13.git/commit
flag: recover panic when calling String on zero value in PrintDefaults
authorAndrew Gerrand <adg@golang.org>
Tue, 29 Mar 2022 23:37:07 +0000 (10:37 +1100)
committerGopher Robot <gobot@golang.org>
Fri, 1 Apr 2022 03:43:34 +0000 (03:43 +0000)
commit029d2c4524e729dbd913475ca4a5138bb6c5e099
tree8e0eda696ec856ae0f8a36a14d883ee87d85128a
parent9d6c711e3c7f16fd4dd2e812d855e881c6692f3e
flag: recover panic when calling String on zero value in PrintDefaults

When printing the usage message, recover panics when calling String
methods on reflect-constructed flag.Value zero values. Collect the panic
messages and include them at the end of the PrintDefaults output so that
the programmer knows to fix the panic.

Fixes #28667

Change-Id: Ic4378a5813a2e26f063d5580d678add65ece8f97
Reviewed-on: https://go-review.googlesource.com/c/go/+/396574
Run-TryBot: Andrew Gerrand <adg@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Trust: Andrew Gerrand <adg@golang.org>
src/flag/flag.go
src/flag/flag_test.go