diff --git a/example_test.go b/example_test.go index fffdbec2..e1a5a92b 100644 --- a/example_test.go +++ b/example_test.go @@ -354,20 +354,22 @@ func ExampleParseWithOptions_prefix() { // Output: {Foo:a} } -// Use a different tag name than `env`. +// Use a different tag name than `env` and `envDefault`. func ExampleParseWithOptions_tagName() { type Config struct { Home string `json:"HOME"` + Page string `json:"PAGE" def:"world"` } os.Setenv("HOME", "hello") var cfg Config if err := ParseWithOptions(&cfg, Options{ - TagName: "json", + TagName: "json", + DefaultValueTagName: "def", }); err != nil { fmt.Println(err) } fmt.Printf("%+v", cfg) - // Output: {Home:hello} + // Output: {Home:hello Page:world} } // If you don't want to set the `env` tag on every field, you can use the