From 6633c2b0fcb6686dead8680cd2c1ed45cb6a89b0 Mon Sep 17 00:00:00 2001 From: "shaun.fu" Date: Mon, 28 Aug 2023 13:49:32 +0800 Subject: [PATCH] fix: check interface value --- get.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/get.go b/get.go index 0dc3a47..5745c78 100644 --- a/get.go +++ b/get.go @@ -14,6 +14,10 @@ func (e *ecp) getValue(config interface{}, keyName string) (reflect.Value, error if !v.IsValid() { return reflect.Value{}, fmt.Errorf("key %s not found", keyName) } + + if !v.CanInterface() { + return reflect.Value{}, fmt.Errorf("bad structure field %s", keyName) + } return v, nil }