diff options
| author | Alex Flint <[email protected]> | 2021-04-19 19:27:31 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-04-19 19:27:31 -0700 |
| commit | 6a01a15f75472271568c732c1191e9d33a5fc54c (patch) | |
| tree | 4accbdd65152994d4e2b043ad81751dce86af93e /example_test.go | |
| parent | f4eb7f3a585abd65b0568428b2b9fde8cebffb6a (diff) | |
| parent | d4b9b2a00813ef6f28f75a685bd868aab4609ec4 (diff) | |
Merge pull request #149 from alexflint/parse-into-map
Add support for parsing into a map
Diffstat (limited to 'example_test.go')
| -rw-r--r-- | example_test.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/example_test.go b/example_test.go index 9091151..5645156 100644 --- a/example_test.go +++ b/example_test.go @@ -82,6 +82,19 @@ func Example_multipleValues() { // output: Fetching the following IDs from localhost: [1 2 3] } +// This example demonstrates arguments with keys and values +func Example_mappings() { + // The args you would pass in on the command line + os.Args = split("./example --userids john=123 mary=456") + + var args struct { + UserIDs map[string]int + } + MustParse(&args) + fmt.Println(args.UserIDs) + // output: map[john:123 mary:456] +} + // This eample demonstrates multiple value arguments that can be mixed with // other arguments. func Example_multipleMixed() { |
