Closed

Description
Defining a flag with a name that has been previously defined results in the following:
package main
import (
"flag"
)
func main() {
fs := flag.NewFlagSet("sample", flag.ExitOnError)
_ = fs.String("name", "", "name value")
_ = fs.String("name", "", "name value")
fs.Parse([]string{`--name`, `test`})
}
sample flag redefined: name
panic: sample flag redefined: name
goroutine 1 [running]:
flag.(*FlagSet).Var(0x430180, 0x147130, 0x40c158, 0x115596, 0x4, 0x11628a, 0xa, 0x7a61)
/usr/local/go/src/flag/flag.go:850 +0x520
flag.(*FlagSet).StringVar(...)
/usr/local/go/src/flag/flag.go:753
flag.(*FlagSet).String(0x430180, 0x115596, 0x4, 0x0, 0x0, 0x11628a, 0xa, 0x7a61, 0x40c150, 0x7a61)
/usr/local/go/src/flag/flag.go:766 +0xc0
main.main()
/tmp/sandbox904772544/main.go:11 +0xc0
This is OK, but the documentation does not seem to mention that flag names need to be unique for each FlagSet, nor that a panic will occur when trying to create a flag with an already-defined name.