Documentation
¶
Index ¶
- func StringSlice(name string, value []string, usage string) *[]string
- func StringSliceVar(p *[]string, name string, value []string, usage string)
- func StringSliceVarWithFlagSet(f *flag.FlagSet, p *[]string, name string, value []string, usage string)
- func StringSliceWithFlagSet(f *flag.FlagSet, name string, value []string, usage string) *[]string
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StringSlice ¶
StringSlice defines an []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.
func StringSliceVar ¶
StringSliceVar 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.
Example ¶
var infos []string
ResetForTesting(nil)
fs := flag.NewFlagSet("demo", flag.ContinueOnError)
fs.SetOutput(os.Stdout)
flag_.StringSliceVarWithFlagSet(fs, &infos, "i", []string{"hello", "world"}, "info arrays")
fs.PrintDefaults()
fmt.Printf("infos before parse: %q\n", infos)
_ = fs.Parse([]string{"-i", "golang", "-i", "flag", "-i", "string slice"})
fmt.Printf("infos after parse: %q\n", infos)
Output: -i value info arrays (default &["hello" "world"]) infos before parse: ["hello" "world"] infos after parse: ["golang" "flag" "string slice"]
func StringSliceVarWithFlagSet ¶
func StringSliceVarWithFlagSet(f *flag.FlagSet, p *[]string, name string, value []string, usage string)
StringSliceVarWithFlagSet 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.
func StringSliceWithFlagSet ¶
StringSliceWithFlagSet defines an []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.
Types ¶
This section is empty.