mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-24 01:08:31 +02:00
fix: nil panic on unmarshaling zero value
This commit is contained in:
@@ -314,7 +314,7 @@ func Convert(src reflect.Value, dst reflect.Value, checkValidateTag bool) gperr.
|
|||||||
return gperr.Errorf("convert: dst is %w", ErrNilValue)
|
return gperr.Errorf("convert: dst is %w", ErrNilValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !src.IsValid() {
|
if !src.IsValid() || src.IsZero() {
|
||||||
if dst.CanSet() {
|
if dst.CanSet() {
|
||||||
dst.Set(reflect.Zero(dst.Type()))
|
dst.Set(reflect.Zero(dst.Type()))
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user