()
| 55 | } |
| 56 | |
| 57 | func ExampleParse_required() { |
| 58 | type Config struct { |
| 59 | Nope string `env:"NOPE,required"` |
| 60 | } |
| 61 | var cfg Config |
| 62 | if err := Parse(&cfg); err != nil { |
| 63 | fmt.Println(err) |
| 64 | } |
| 65 | fmt.Printf("%+v", cfg) |
| 66 | // Output: env: required environment variable "NOPE" is not set |
| 67 | // {Nope:} |
| 68 | } |
| 69 | |
| 70 | // While `required` demands the environment variable to be set, it doesn't check |
| 71 | // its value. If you want to make sure the environment is set and not empty, you |