From ac78b2fa50426499717df1915bc86c21885ffc77 Mon Sep 17 00:00:00 2001 From: John Guo Date: Wed, 15 Sep 2021 21:46:58 +0800 Subject: [PATCH] fix ci issue --- container/garray/garray_z_unit_normal_any_array_test.go | 2 +- util/gconv/gconv_struct.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/container/garray/garray_z_unit_normal_any_array_test.go b/container/garray/garray_z_unit_normal_any_array_test.go index 004e9bfd3..39b57be19 100644 --- a/container/garray/garray_z_unit_normal_any_array_test.go +++ b/container/garray/garray_z_unit_normal_any_array_test.go @@ -709,7 +709,7 @@ func TestArray_UnmarshalValue(t *testing.T) { "name": "john", "array": []byte(`[1,2,3]`), }, &v) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(v.Name, "john") t.Assert(v.Array.Slice(), g.Slice{1, 2, 3}) }) diff --git a/util/gconv/gconv_struct.go b/util/gconv/gconv_struct.go index 886ef857d..0d5147d1b 100644 --- a/util/gconv/gconv_struct.go +++ b/util/gconv/gconv_struct.go @@ -59,6 +59,9 @@ func doStructWithJsonCheck(params interface{}, pointer interface{}) (err error, if json.Valid(r) { if rv, ok := pointer.(reflect.Value); ok { if rv.Kind() == reflect.Ptr { + if rv.IsNil() { + return nil, false + } return json.UnmarshalUseNumber(r, rv.Interface()), true } else if rv.CanAddr() { return json.UnmarshalUseNumber(r, rv.Addr().Interface()), true @@ -71,6 +74,9 @@ func doStructWithJsonCheck(params interface{}, pointer interface{}) (err error, if paramsBytes := []byte(r); json.Valid(paramsBytes) { if rv, ok := pointer.(reflect.Value); ok { if rv.Kind() == reflect.Ptr { + if rv.IsNil() { + return nil, false + } return json.UnmarshalUseNumber(paramsBytes, rv.Interface()), true } else if rv.CanAddr() { return json.UnmarshalUseNumber(paramsBytes, rv.Addr().Interface()), true