Skip to content

Commit

Permalink
fix(dereference embedded pointers to structs)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgreben committed Dec 18, 2023
1 parent 96e1aef commit d93ddd9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion checker/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ func fetchField(t reflect.Type, name string) (reflect.StructField, bool) {
for i := 0; i < t.NumField(); i++ {
anon := t.Field(i)
if anon.Anonymous {
if field, ok := fetchField(anon.Type, name); ok {
anonType := anon.Type
for anonType.Kind() == reflect.Pointer {
anonType = anonType.Elem()
}
if field, ok := fetchField(anonType, name); ok {
field.Index = append(anon.Index, field.Index...)
return field, true
}
Expand Down

0 comments on commit d93ddd9

Please sign in to comment.