diff options
| author | Alex Flint <[email protected]> | 2021-09-18 08:55:40 -0700 |
|---|---|---|
| committer | Alex Flint <[email protected]> | 2021-09-18 08:55:40 -0700 |
| commit | f2f876420ce7c64673cdf97ed8071db8ef46e5f2 (patch) | |
| tree | 8441653724d058566ba492200900a5c6cca84d17 /example_test.go | |
| parent | 7cc8da61cf3da353167fcc83ad4e751f3c82ec97 (diff) | |
| parent | 66cb696e79be30bc979cb003ef8bdecc78266ced (diff) | |
Merge remote-tracking branch 'origin/master' into usage-for-subcommands
Diffstat (limited to 'example_test.go')
| -rw-r--r-- | example_test.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/example_test.go b/example_test.go index 2b7ce00..20b9225 100644 --- a/example_test.go +++ b/example_test.go @@ -2,8 +2,12 @@ package arg import ( "fmt" + "net" + "net/mail" + "net/url" "os" "strings" + "time" ) func split(s string) []string { @@ -470,3 +474,34 @@ func Example_subcommand() { // output: // commit requested with message "what-this-commit-is-about" } + +func Example_allSupportedTypes() { + // These are the args you would pass in on the command line + os.Args = []string{} + + var args struct { + Bool bool + Byte byte + Rune rune + Int int + Int8 int8 + Int16 int16 + Int32 int32 + Int64 int64 + Float32 float32 + Float64 float64 + String string + Duration time.Duration + URL url.URL + Email mail.Address + MAC net.HardwareAddr + } + + // go-arg supports each of the types above, as well as pointers to any of + // the above and slices of any of the above. It also supports any types that + // implements encoding.TextUnmarshaler. + + MustParse(&args) + + // output: +} |
