fix(serialization): nil and pointer handling in ConvertSlice

This commit is contained in:
yusing
2026-01-16 10:09:47 +08:00
parent 8399a9ece7
commit 7d466625d6

View File

@@ -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)
}