go-zero
go-zero copied to clipboard
api file anonymous struct syntax
Is your feature request related to a problem? Please describe. When I am writing the api file, I want to strictly control the returned fields, then there will be type declarations like AAA, AAA1, but I don't want this kind of declaration and I think the readability is not good.
Describe the solution you'd like I want to support anonymous types when writing api files, like:
type (
AAA {
Field1 int64 `json:"field1"`
Field2 int64 `json:"field2"`
BBB struct {
Field1 int64 `json:"field1"`
Field2 int64 `json:"field2"`
}
}
)
and then generate a struct like this in the generated types.go
file
type AAA struct {
Field1 int64 `json:"field1"`
Field2 int64 `json:"field2"`
BBB AAA_BBB `json:"bbb"`
}
type AAA_BBB struct {
Field1 int64 `json:"field1"`
Field2 int64 `json:"field2"`
}
First of all, this syntax itself is not currently supported, and a syntax error will be reported. However, in the future, pr #2585 will support some new features
Amazing!
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.