env
env copied to clipboard
support complex map types, where the map value can be a struct
The proposal is to support complex map types so that we could do the following
type Test struct {
Str string `env:"DAT_STR"`
Num int `env:"DAT_NUM"`
}
type ComplexConfig struct {
Bar map[string]Test `envPrefix:"BAR_"`
}
t.Setenv("BAR_KEY1_DAT_STR", "b1t")
t.Setenv("BAR_KEY1_DAT_NUM", "201")
This is similar to https://github.com/caarlos0/env/issues/298 but for maps
The key can be any supported value (that are already present in either opts.FuncMap or the default parser list in defaultBuiltInParsers).
I will open a PR for this Issue.