Skip to content

Commit 1cc6019

Browse files
committed
Fix panic on pointer to embedded struct
This commit converts an embedded struct into its original type if it is a pointer. Fixes: #172 Signed-off-by: Chris Tarazi <[email protected]>
1 parent b84068c commit 1cc6019

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

value/reflectcache.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,11 @@ func buildStructCacheEntry(t reflect.Type, infos map[string]*FieldCacheEntry, fi
150150
continue
151151
}
152152
if isInline {
153-
buildStructCacheEntry(field.Type, infos, append(fieldPath, field.Index))
153+
e := field.Type
154+
if field.Type.Kind() == reflect.Ptr {
155+
e = field.Type.Elem()
156+
}
157+
buildStructCacheEntry(e, infos, append(fieldPath, field.Index))
154158
continue
155159
}
156160
info := &FieldCacheEntry{JsonName: jsonName, isOmitEmpty: isOmitempty, fieldPath: append(fieldPath, field.Index), fieldType: field.Type}

0 commit comments

Comments
 (0)