Skip to content

Commit 6248a64

Browse files
atopuzovdmacvicar
authored andcommitted
fix: Process anonymous fields in libvirt XML
1 parent 83e1156 commit 6248a64

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

internal/codegen/parser/libvirtxml.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,17 @@ func (r *LibvirtXMLReflector) ReflectStruct(structType reflect.Type) (*generator
8585
continue
8686
}
8787

88+
if field.Anonymous {
89+
if field.Type.Kind() == reflect.Struct {
90+
embeddedIR, err := r.ReflectStruct(field.Type)
91+
if err != nil {
92+
return nil, fmt.Errorf("analyzing embedded struct %s: %w", field.Type.Name(), err)
93+
}
94+
ir.Fields = append(ir.Fields, embeddedIR.Fields...)
95+
}
96+
continue
97+
}
98+
8899
fieldIR, err := r.analyzeField(typeName, field)
89100
if err != nil {
90101
return nil, fmt.Errorf("analyzing field %s: %w", field.Name, err)
@@ -280,11 +291,6 @@ func (r *LibvirtXMLReflector) analyzeField(structName string, field reflect.Stru
280291
return nil, nil
281292
}
282293

283-
// Skip embedded/anonymous fields
284-
if field.Anonymous {
285-
return nil, nil
286-
}
287-
288294
xmlTag := field.Tag.Get("xml")
289295
if xmlTag == "" {
290296
// Skip fields without XML tags

0 commit comments

Comments
 (0)