mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-20 08:14:03 +01:00
fix(serialization): nil and pointer handling in ConvertSlice
This commit is contained in:
@@ -456,6 +456,18 @@ func Convert(src reflect.Value, dst reflect.Value, checkValidateTag bool) gperr.
|
||||
}
|
||||
|
||||
func ConvertSlice(src reflect.Value, dst reflect.Value, checkValidateTag bool) gperr.Error {
|
||||
if dst.Kind() == reflect.Pointer {
|
||||
if dst.IsNil() && !dst.CanSet() {
|
||||
return ErrNilValue
|
||||
}
|
||||
initPtr(dst)
|
||||
dst = dst.Elem()
|
||||
}
|
||||
|
||||
if !dst.CanSet() {
|
||||
return ErrUnsettable.Subject(dst.Type().String())
|
||||
}
|
||||
|
||||
if src.Kind() != reflect.Slice {
|
||||
return Convert(src, dst, checkValidateTag)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user