]> Cypherpunks.ru repositories - gostls13.git/commit
flag: correct zero values when printing defaults
authorjimmyfrasche <soapboxcicero@gmail.com>
Sun, 1 Apr 2018 18:15:17 +0000 (11:15 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Sun, 1 Apr 2018 20:17:22 +0000 (20:17 +0000)
commit3c588b3fe7e1394f7df981284f1dc4c0a2b32b14
tree2b092e5a839d20b854f447ded0069d986b8253f2
parente55475ca3b6652d2d24b7bf48bcaf3e216c3ed68
flag: correct zero values when printing defaults

When the flag package first begin printing nonzero defaults, the test
was against a fixed set of string representations of zero values.
This worked until the string representation of a time.Duration
changed from "0" to "0s", causing the zero Duration to register as
nonzero. The flag package then added reflect-based code that fell back
to the old test. This failed to work when a nonzero default for a flag
happened to be the string representation of one the original fixed set
of zero values in the original test. This change removes the original
test, allowing the reflect-based code to be the only deciding factor.

Fixes #23543

Change-Id: I582ce554d6729e336fdd96fb27340674c15350d8
Reviewed-on: https://go-review.googlesource.com/103867
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/flag/flag.go
src/flag/flag_test.go