-
-
Notifications
You must be signed in to change notification settings - Fork 272
Open
Description
I would like to be able to use environment variables to set a default value to an empty string if the environment variable is set:
type MyConfig struct {
Variable string `env:"VARIABLE"`
}
func NewConfig() (*MyConfig, error) {
cfg := &MyConfig{
Variable: "default",
}
if err := env.Parse(cfg); err != nil {
return nil, err
}
return cfg, nil
}If VARIABLE="" is set, the env package would just completely skip overwriting the default value to become empty as well.
Basically, I would like to have an option to skip this empty check here:
Lines 507 to 509 in 3a3ea05
| if value != "" && (!opts.SetDefaultsForZeroValuesOnly || refField.IsZero()) { | |
| return set(refField, refTypeField, value, opts.FuncMap) | |
| } |
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels