From a181e358658fa57619e9c00f81c083776fc0a3f3 Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Sun, 16 Jul 2023 11:11:16 +0800 Subject: [PATCH] chore: structure support decode pointer --- common/structure/structure.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/structure/structure.go b/common/structure/structure.go index 85254e24..fde22309 100644 --- a/common/structure/structure.go +++ b/common/structure/structure.go @@ -96,6 +96,11 @@ func (d *Decoder) decode(name string, data any, val reflect.Value) error { return d.decodeFloat(name, data, val) } switch kind { + case reflect.Pointer: + if val.IsNil() { + val.Set(reflect.New(val.Type().Elem())) + } + return d.decode(name, data, val.Elem()) case reflect.String: return d.decodeString(name, data, val) case reflect.Bool: