summaryrefslogtreecommitdiff
path: root/src/cmd/godoc/main.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2010-03-29 17:37:22 -0700
committerRob Pike <r@golang.org>2010-03-29 17:37:22 -0700
commit0eff02c3398a847baf2042750790676fe4e52100 (patch)
tree58eea0f4c34f1168233cc6a33c4ace50e41ca9d1 /src/cmd/godoc/main.go
parent218421ebcdaee59bac41af0fbdf50a525d5b5f52 (diff)
downloadgolang-0eff02c3398a847baf2042750790676fe4e52100.tar.gz
Flags: add user-defined flag types. The change is really no code; it's just publishing
the set() method and add() functions. But we rename add() to Var() for consistency. Also rename FlagValue to Value for simplicity. Also, delete the check for multiple settings for a flag. This makes it possible to define a flag that collects values, such as into a slice of strings. type flagVar []string func (f *flagVar) String() string { return fmt.Sprint(v) } func (f *flagVar) Set(value string) bool { if v == nil { v = make(flagVar, 1) } else { nv := make(flagVar, len(v)+1) copy(nv, v) v = nv } v[len(v)-1] = value return true } var v flagVar func main() { flag.Var(&v, "testV", "multiple values build []string") flag.Parse() fmt.Printf("v = %v\n", v) } R=rsc CC=golang-dev http://codereview.appspot.com/842041
Diffstat (limited to 'src/cmd/godoc/main.go')
0 files changed, 0 insertions, 0 deletions