Parse the environment into a struct.
()
| 28 | |
| 29 | // Parse the environment into a struct. |
| 30 | func ExampleParse() { |
| 31 | type Config struct { |
| 32 | Home string `env:"HOME"` |
| 33 | } |
| 34 | os.Setenv("HOME", "/tmp/fakehome") |
| 35 | var cfg Config |
| 36 | if err := Parse(&cfg); err != nil { |
| 37 | fmt.Println(err) |
| 38 | } |
| 39 | fmt.Printf("%+v", cfg) |
| 40 | // Output: {Home:/tmp/fakehome} |
| 41 | } |
| 42 | |
| 43 | // Parse the environment into a struct using generics. |
| 44 | func ExampleParseAs() { |