fix: nil panic on unmarshaling zero value

This commit is contained in:
yusing 2025-04-30 12:06:49 +08:00
parent 7a5afc3612
commit 80e59bb481

View file

@ -314,7 +314,7 @@ func Convert(src reflect.Value, dst reflect.Value, checkValidateTag bool) gperr.
return gperr.Errorf("convert: dst is %w", ErrNilValue)
}
if !src.IsValid() {
if !src.IsValid() || src.IsZero() {
if dst.CanSet() {
dst.Set(reflect.Zero(dst.Type()))
return nil