mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-24 09:18:31 +02:00
fix(serialization): nil and pointer handling in ConvertSlice
This commit is contained in:
committed by
github-actions[bot]
parent
3c8edfb1ae
commit
bcf88ac4d6
@@ -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 {
|
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 {
|
if src.Kind() != reflect.Slice {
|
||||||
return Convert(src, dst, checkValidateTag)
|
return Convert(src, dst, checkValidateTag)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user