Setting prefixes for the entire config.
()
| 339 | |
| 340 | // Setting prefixes for the entire config. |
| 341 | func ExampleParseWithOptions_prefix() { |
| 342 | type Config struct { |
| 343 | Foo string `env:"FOO"` |
| 344 | } |
| 345 | os.Setenv("MY_APP_FOO", "a") |
| 346 | var cfg Config |
| 347 | if err := ParseWithOptions(&cfg, Options{ |
| 348 | Prefix: "MY_APP_", |
| 349 | }); err != nil { |
| 350 | fmt.Println(err) |
| 351 | } |
| 352 | fmt.Printf("%+v", cfg) |
| 353 | // Output: {Foo:a} |
| 354 | } |
| 355 | |
| 356 | // Use a different tag name than `env` and `envDefault`. |
| 357 | func ExampleParseWithOptions_tagName() { |
nothing calls this directly
no test coverage detected