Fix: config parse panic

This commit is contained in:
Dreamacro 2020-03-19 11:04:56 +08:00
parent 082847b403
commit 230e01f078

View file

@ -216,6 +216,11 @@ func (d *Decoder) decodeMapFromMap(name string, dataVal reflect.Value, val refle
} }
v := dataVal.MapIndex(k).Interface() v := dataVal.MapIndex(k).Interface()
if v == nil {
errors = append(errors, fmt.Sprintf("filed %s invalid", fieldName))
continue
}
currentVal := reflect.Indirect(reflect.New(valElemType)) currentVal := reflect.Indirect(reflect.New(valElemType))
if err := d.decode(fieldName, v, currentVal); err != nil { if err := d.decode(fieldName, v, currentVal); err != nil {
errors = append(errors, err.Error()) errors = append(errors, err.Error())