Documentation
¶
Overview ¶
Package stringmapflag provides a flag.Value that, when parsed, augments a map[string]string with the supplied parameter. The parameter is expressed as a key[=value] option.
Example ¶
Assuming the flag option, "opt", is bound to a stringmapflag.Value, and the following arguments are parsed:
-opt foo=bar -opt baz
The resulting map would be equivalent to: map[string]string {"foo": "bar", "baz": ""}
Example ¶
v := new(Value)
fs := flag.NewFlagSet("test", flag.ContinueOnError)
fs.Var(v, "option", "Appends a key[=value] option.")
// Simulate user input.
if err := fs.Parse([]string{
"-option", "foo=bar",
"-option", "baz",
}); err != nil {
panic(err)
}
m, _ := json.MarshalIndent(v, "", " ")
fmt.Println("Parsed options:", string(m))
Output: Parsed options: { "baz": "", "foo": "bar" }
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
Source Files
¶
- stringmapflag.go
Click to show internal directories.
Click to hide internal directories.