diff options
| author | Alex Flint <[email protected]> | 2021-04-19 14:01:29 -0700 |
|---|---|---|
| committer | Alex Flint <[email protected]> | 2021-04-19 14:01:29 -0700 |
| commit | 57f610284f51a9f47c359bb782d7e30f3d6d075d (patch) | |
| tree | 46ffb6714bc6d8f56491bebfee0dfbc9bf086c9f | |
| parent | 91214e01ea30c8615fde40cf08934d9fb9517376 (diff) | |
add an runnable example for mappings
| -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() { |
