flag

package
v1.2.117 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func StringSlice

func StringSlice(name string, value []string, usage string) *[]string

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

func StringSliceVar(p *[]string, name string, value []string, usage string)

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

func StringSliceWithFlagSet(f *flag.FlagSet, name string, value []string, usage string) *[]string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL