mirror of
https://github.com/yusing/godoxy.git
synced 2025-06-15 14:36:48 +02:00
fix(serialization): call of reflect.Value.IsNil on string Value
This commit is contained in:
parent
ecc9d306d1
commit
1d546624de
1 changed files with 9 additions and 12 deletions
|
@ -152,20 +152,17 @@ func dive(dst reflect.Value) (v reflect.Value, t reflect.Type, err gperr.Error)
|
||||||
}
|
}
|
||||||
dst = dst.Elem()
|
dst = dst.Elem()
|
||||||
dstT = dst.Type()
|
dstT = dst.Type()
|
||||||
case reflect.Struct:
|
case reflect.Map:
|
||||||
|
if dst.IsNil() {
|
||||||
|
dst.Set(reflect.MakeMap(dstT))
|
||||||
|
}
|
||||||
|
return dst, dstT, nil
|
||||||
|
case reflect.Slice:
|
||||||
|
if dst.IsNil() {
|
||||||
|
dst.Set(reflect.MakeSlice(dstT, 0, 0))
|
||||||
|
}
|
||||||
return dst, dstT, nil
|
return dst, dstT, nil
|
||||||
default:
|
default:
|
||||||
if dst.IsNil() {
|
|
||||||
switch dst.Kind() {
|
|
||||||
case reflect.Map:
|
|
||||||
dst.Set(reflect.MakeMap(dstT))
|
|
||||||
case reflect.Slice:
|
|
||||||
dst.Set(reflect.MakeSlice(dstT, 0, 0))
|
|
||||||
default:
|
|
||||||
err = gperr.Errorf("deserialize: %w for dst %s", ErrInvalidType, dstT.String())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return dst, dstT, nil
|
return dst, dstT, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue