diff --git a/README.md b/README.md index c516c51..0ad03bc 100644 --- a/README.md +++ b/README.md @@ -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