Skip to content

Commit 10c5c82

Browse files
committed
Fix embedded fields
1 parent f85f945 commit 10c5c82

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

model/model.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -598,12 +598,17 @@ func (pt PredeclaredType) String(map[string]string, string) string { return stri
598598
func (pt PredeclaredType) addImports(map[string]bool) {}
599599

600600
type Field struct {
601-
Name string
602-
Type Type
601+
Name string
602+
Type Type
603+
Anonymous bool
603604
}
604605

605606
func (f *Field) String(pm map[string]string, pkgOverride string) string {
606-
return f.Name + " " + f.Type.String(pm, pkgOverride)
607+
if f.Anonymous {
608+
return f.Type.String(pm, pkgOverride)
609+
} else {
610+
return f.Name + " " + f.Type.String(pm, pkgOverride)
611+
}
607612
}
608613

609614
// StructType is a struct type.
@@ -885,8 +890,9 @@ func (pkg *Package) unnamedTypeFromType(t reflect.Type) (Type, error) {
885890
}
886891

887892
m := &Field{
888-
Name: ft.Name,
889-
Type: typ,
893+
Name: ft.Name,
894+
Type: typ,
895+
Anonymous: ft.Anonymous,
890896
}
891897

892898
fields = append(fields, m)

0 commit comments

Comments
 (0)