From 32f7322b82306209283036053b75ae0a8e7411c6 Mon Sep 17 00:00:00 2001 From: Tony Chen Date: Tue, 16 Mar 2021 23:34:20 +0800 Subject: [PATCH] fix nil target (#774) --- encoding/json/json.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/encoding/json/json.go b/encoding/json/json.go index 1f57c2599..c03ceb762 100644 --- a/encoding/json/json.go +++ b/encoding/json/json.go @@ -24,7 +24,7 @@ func (codec) Marshal(v interface{}) ([]byte, error) { func (codec) Unmarshal(data []byte, v interface{}) error { rv := reflect.ValueOf(v) for rv.Kind() == reflect.Ptr { - if rv.IsNil() && rv.CanSet() { + if rv.IsNil() && rv.CanInterface() { rv.Set(reflect.New(rv.Type().Elem())) v = rv.Interface() }