mirror of
https://github.com/golang/go
synced 2024-11-15 12:10:22 -07:00
[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 »»»
This commit is contained in:
parent
7de2fc41a2
commit
536be05e32
@ -620,8 +620,9 @@ func (f *FlagSet) Var(value Value, name string, usage string) {
|
|||||||
flag := &Flag{name, usage, value, value.String()}
|
flag := &Flag{name, usage, value, value.String()}
|
||||||
_, alreadythere := f.formal[name]
|
_, alreadythere := f.formal[name]
|
||||||
if alreadythere {
|
if alreadythere {
|
||||||
fmt.Fprintf(f.out(), "%s flag redefined: %s\n", f.name, name)
|
msg := fmt.Sprintf("%s flag redefined: %s", f.name, name)
|
||||||
panic("flag redefinition") // Happens only if flags are declared with identical names
|
fmt.Fprintln(f.out(), msg)
|
||||||
|
panic(msg) // Happens only if flags are declared with identical names
|
||||||
}
|
}
|
||||||
if f.formal == nil {
|
if f.formal == nil {
|
||||||
f.formal = make(map[string]*Flag)
|
f.formal = make(map[string]*Flag)
|
||||||
|
Loading…
Reference in New Issue
Block a user