From 329f6b90f7761ceef56b5fecd2f0378c68e2bc70 Mon Sep 17 00:00:00 2001 From: John Guo Date: Fri, 11 Mar 2022 15:26:01 +0800 Subject: [PATCH] improve gutil.Dump feature --- util/gutil/gutil_dump.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/gutil/gutil_dump.go b/util/gutil/gutil_dump.go index 32cc09589..9dde76fd4 100644 --- a/util/gutil/gutil_dump.go +++ b/util/gutil/gutil_dump.go @@ -87,7 +87,7 @@ func doDump(value interface{}, indent string, buffer *bytes.Buffer, option doDum var reflectValue reflect.Value if v, ok := value.(reflect.Value); ok { reflectValue = v - if v.CanInterface() { + if v.IsValid() && v.CanInterface() { value = v.Interface() } else { if convertedValue, ok := reflection.ValueToInterface(v); ok { @@ -410,7 +410,7 @@ func doDumpBool(in doDumpInternalInput) { func doDumpDefault(in doDumpInternalInput) { var s string - if in.ReflectValue.CanInterface() { + if in.ReflectValue.IsValid() && in.ReflectValue.CanInterface() { s = fmt.Sprintf("%v", in.ReflectValue.Interface()) } if s == "" {