Skip to content

Commit a043d24

Browse files
authored
Merge pull request #16 from iTryIt/main
fix nil ptr panic
2 parents d9efa6a + 68ce3ab commit a043d24

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

filter/parser.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ func (t *fieldNodeTree) parseAny(key, scene string, valueOf reflect.Value, isSel
1717
TakePointerValue: //取指针的值
1818
switch typeOf.Kind() {
1919
case reflect.Ptr: //如果是指针类型则取值重新判断类型
20-
valueOf = valueOf.Elem()
21-
typeOf = typeOf.Elem()
22-
goto TakePointerValue
20+
if !valueOf.IsNil() {
21+
valueOf = valueOf.Elem()
22+
typeOf = typeOf.Elem()
23+
goto TakePointerValue
24+
} else {
25+
parserNilInterface(t, key)
26+
}
2327
case reflect.Interface:
2428
if !valueOf.IsNil() {
2529
valueOf = reflect.ValueOf(valueOf.Interface())

0 commit comments

Comments
 (0)