diff options
| author | Alex Flint <[email protected]> | 2019-10-21 23:13:41 -0700 |
|---|---|---|
| committer | Alex Flint <[email protected]> | 2019-10-21 23:13:41 -0700 |
| commit | 7ac060af1863205e7dfcc103b90711767e45e2a8 (patch) | |
| tree | b069ddd515ae769f7c99eeaf087f94cb634ed110 | |
| parent | 809e9060d082454ac2ece1960fa2c584ba01816d (diff) | |
update documentation to new way of specifying defaults
| -rw-r--r-- | README.md | 6 | ||||
| -rw-r--r-- | example_test.go | 5 |
2 files changed, 4 insertions, 7 deletions
@@ -142,10 +142,9 @@ Options: ```go var args struct { - Foo string + Foo string `default:"abc"` Bar bool } -args.Foo = "default value" arg.MustParse(&args) ``` @@ -307,9 +306,8 @@ func (n *NameDotName) MarshalText() ([]byte, error) { func main() { var args struct { - Name NameDotName + Name NameDotName `default:"file.txt"` } - args.Name = NameDotName{"file", "txt"} // set default value arg.MustParse(&args) fmt.Printf("%#v\n", args.Name) } diff --git a/example_test.go b/example_test.go index 2188253..f71fbeb 100644 --- a/example_test.go +++ b/example_test.go @@ -30,12 +30,11 @@ func Example_defaultValues() { os.Args = split("./example") var args struct { - Foo string + Foo string `default:"abc"` } - args.Foo = "default value" MustParse(&args) fmt.Println(args.Foo) - // output: default value + // output: abc } // This example demonstrates arguments that are required |
