Commit 536be05e authored by David Symonds's avatar David Symonds

[release-branch.go1] flag: include flag name in redefinition panic.

««« backport 64a249c65d51
flag: include flag name in redefinition panic.

R=golang-dev, rsc, r
CC=golang-dev
https://golang.org/cl/6250043

»»»
parent 7de2fc41
......@@ -620,8 +620,9 @@ func (f *FlagSet) Var(value Value, name string, usage string) {
flag := &Flag{name, usage, value, value.String()}
_, alreadythere := f.formal[name]
if alreadythere {
fmt.Fprintf(f.out(), "%s flag redefined: %s\n", f.name, name)
panic("flag redefinition") // Happens only if flags are declared with identical names
msg := fmt.Sprintf("%s flag redefined: %s", f.name, name)
fmt.Fprintln(f.out(), msg)
panic(msg) // Happens only if flags are declared with identical names
}
if f.formal == nil {
f.formal = make(map[string]*Flag)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment