fix crash when using environment variables and config file is missing (#103)

This commit is contained in:
aler9 2020-10-19 00:22:16 +02:00
parent 64e38f7db4
commit 57877df875
2 changed files with 25 additions and 0 deletions

View file

@ -81,6 +81,11 @@ func process(env map[string]string, envKey string, rv reflect.Value) error {
}
mapKey = strings.ToLower(mapKey)
// initialize only if there's at least one key
if rv.IsNil() {
rv.Set(reflect.MakeMap(rt))
}
nv := rv.MapIndex(reflect.ValueOf(mapKey))
zero := reflect.Value{}
if nv == zero {