env: no parser found for field "<FIELD>" of type "map[string]string
kotyara85 opened this issue · 1 comments
kotyara85 commented
Started after migrating to go 1.18
if err := env.ParseWithFuncs(&cfg, map[reflect.Type]env.ParserFunc{
reflect.TypeOf(map[string]string{}): func(v string) (interface{}, error) {
slice := strings.Split(v, ",")
ret := map[string]string{}
for _, el := range slice {
entry := strings.Split(el, "=")
if len(entry) == 2 && entry[0] != "" && entry[1] != "" {
key := strings.TrimSpace(entry[0])
value := strings.TrimSpace(entry[1])
ret[key] = value
}
}
return ret, nil
},
}); err != nil {
log.Fatal(err)
}
kotyara85 commented
I had another env.Parse which would trigger the error