package pflag// -- stringArray Valuetype stringArrayValue struct { value *[]string changed bool}func newStringArrayValue( []string, *[]string) *stringArrayValue { := new(stringArrayValue) .value = *.value = return}func ( *stringArrayValue) ( string) error {if !.changed { *.value = []string{} .changed = true } else { *.value = append(*.value, ) }returnnil}func ( *stringArrayValue) ( string) error { *.value = append(*.value, )returnnil}func ( *stringArrayValue) ( []string) error { := make([]string, len())for , := range { [] = } *.value = returnnil}func ( *stringArrayValue) () []string { := make([]string, len(*.value))for , := range *.value { [] = }return}func ( *stringArrayValue) () string {return"stringArray"}func ( *stringArrayValue) () string { , := writeAsCSV(*.value)return"[" + + "]"}func stringArrayConv( string) (interface{}, error) { = [1 : len()-1]// An empty string would cause a array with one (empty) stringiflen() == 0 {return []string{}, nil }returnreadAsCSV()}// GetStringArray return the []string value of a flag with the given namefunc ( *FlagSet) ( string) ([]string, error) { , := .getFlagType(, "stringArray", stringArrayConv)if != nil {return []string{}, }return .([]string), nil}// StringArrayVar defines a string flag with specified name, default value, and usage string.// The argument p points to a []string variable in which to store the values of the multiple flags.// The value of each argument will not try to be separated by comma. Use a StringSlice for that.func ( *FlagSet) ( *[]string, string, []string, string) { .VarP(newStringArrayValue(, ), , "", )}// StringArrayVarP is like StringArrayVar, but accepts a shorthand letter that can be used after a single dash.func ( *FlagSet) ( *[]string, , string, []string, string) { .VarP(newStringArrayValue(, ), , , )}// StringArrayVar defines a string flag with specified name, default value, and usage string.// The argument p points to a []string variable in which to store the value of the flag.// The value of each argument will not try to be separated by comma. Use a StringSlice for that.func ( *[]string, string, []string, string) {CommandLine.VarP(newStringArrayValue(, ), , "", )}// StringArrayVarP is like StringArrayVar, but accepts a shorthand letter that can be used after a single dash.func ( *[]string, , string, []string, string) {CommandLine.VarP(newStringArrayValue(, ), , , )}// StringArray defines a string flag with specified name, default value, and usage string.// The return value is the address of a []string variable that stores the value of the flag.// The value of each argument will not try to be separated by comma. Use a StringSlice for that.func ( *FlagSet) ( string, []string, string) *[]string { := []string{} .StringArrayVarP(&, , "", , )return &}// StringArrayP is like StringArray, but accepts a shorthand letter that can be used after a single dash.func ( *FlagSet) (, string, []string, string) *[]string { := []string{} .StringArrayVarP(&, , , , )return &}// StringArray defines a string flag with specified name, default value, and usage string.// The return value is the address of a []string variable that stores the value of the flag.// The value of each argument will not try to be separated by comma. Use a StringSlice for that.func ( string, []string, string) *[]string {returnCommandLine.StringArrayP(, "", , )}// StringArrayP is like StringArray, but accepts a shorthand letter that can be used after a single dash.func (, string, []string, string) *[]string {returnCommandLine.StringArrayP(, , , )}
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.