(goctl): fix nested struct generation (#4281)

This commit is contained in:
kesonan
2024-07-28 23:40:25 +08:00
committed by GitHub
parent eeda6efae7
commit ee643a945e
6 changed files with 32 additions and 17 deletions

View File

@@ -30,9 +30,19 @@ func (t DefineStruct) Documents() []string {
return t.Docs
}
// IsNestedStruct returns whether the structure is nested.
func (t DefineStruct) IsNestedStruct() bool {
return len(t.Members) > 0
// Name returns a structure string, such as User
func (t NestedStruct) Name() string {
return t.RawName
}
// Comments returns the comments of struct
func (t NestedStruct) Comments() []string {
return nil
}
// Documents returns the documents of struct
func (t NestedStruct) Documents() []string {
return t.Docs
}
// Name returns a map string, such as map[string]int

View File

@@ -105,6 +105,13 @@ type (
Docs Doc
}
// NestedStruct describes a structure nested in structure.
NestedStruct struct {
RawName string
Members []Member
Docs Doc
}
// PrimitiveType describes the basic golang type, such as bool,int32,int64, ...
PrimitiveType struct {
RawName string