Documentation
¶
Overview ¶
Package stringlist implements a custom "stringlist" flag It accepts comma separated values and repeated flag occurrence. Leading and trailing whitespace will be trimmed.
Usage:
var (
myFlag stringlist.Value
)
func init() {
flag.Var(&myFlag, "myflag", "a list of strings")
}
Or:
var (
myFlag = stringlist.Flag("myflag", "a list of strings")
)
func foo() {
for _, i := range *myFlag {
// note: you need to dereference the slice
}
}
Or:
var (
myFlag []string
)
func init() {
stringlist.Var(&myFlag, "myflag", "a list of strings")
}
func main() {
flag.Parse()
for _, i := range myFlag {
// note: no need to dereference the slice
}
}
If you invoke it with:
--myflag a,b --myflag c --myflag "c, d"
myFlag will contain: []string{"a", "b", "c", "d"}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Slice ¶ added in v1.1.0
type Slice struct {
// contains filtered or unexported fields
}