From 57030f26b0062fa8eda21b3a73b7665deab88c76 Mon Sep 17 00:00:00 2001 From: Jes Cok Date: Tue, 1 Oct 2024 11:07:23 +0800 Subject: [PATCH] 10 Change-Id: I49f14328841cc2e950e244f4cd98c4dcea1f0987 --- src/encoding/json/encode.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/encoding/json/encode.go b/src/encoding/json/encode.go index 55fca6e0e1..02522f088a 100644 --- a/src/encoding/json/encode.go +++ b/src/encoding/json/encode.go @@ -1192,7 +1192,9 @@ func typeFields(t reflect.Type) structFields { field.isZero = func(v reflect.Value) bool { // Avoid panics calling IsZero on a nil interface or // non-nil interface with nil pointer. - return v.IsNil() || (v.Elem().Kind() == reflect.Pointer && v.Elem().IsNil()) || v.Interface().(isZeroer).IsZero() + return v.IsNil() || + (v.Elem().Kind() == reflect.Pointer && v.Elem().IsNil()) || + v.Interface().(isZeroer).IsZero() } case t.Kind() == reflect.Pointer && t.Implements(isZeroerType): field.isZero = func(v reflect.Value) bool {