Skip to content

Commit a3045d5

Browse files
lvan100lianghuan
authored andcommitted
111
1 parent b1a8731 commit a3045d5

File tree

4 files changed

+25
-151
lines changed

4 files changed

+25
-151
lines changed

gen/generator/golang/type.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -128,20 +128,9 @@ const {{$c.Name}} {{$c.Type}} = {{$c.Value}}
128128
{{- end}}
129129
}
130130
131-
// New{{$s.Name}} creates a new instance of the struct and sets default values if defined
132-
func New{{$s.Name}}() *{{$s.Name}} {
133-
return &{{$s.Name}}{
134-
{{- range $f := $s.Fields}}
135-
{{- if $f.Default}}
136-
{{$f.Name}}: {{$f.Default}},
137-
{{- end}}
138-
{{- end}}
139-
}
140-
}
141-
142131
// New implements the Object interface
143132
func (x *{{$s.Name}}) New() any {
144-
return New{{$s.Name}}()
133+
return &{{$s.Name}}{}
145134
}
146135
147136
// Binding extracts non-body values (header, path, query) from *http.Request

gen/testdata/manager/go/manager_http_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ import (
1515
type MyManagerServer struct{}
1616

1717
func (m *MyManagerServer) GetManager(ctx context.Context, req *proto.ManagerReq) *proto.GetManagerResp {
18-
data := proto.NewManager()
19-
data.SetName("Jim")
20-
res := proto.NewGetManagerResp()
21-
res.SetData(data)
22-
return res
18+
return &proto.GetManagerResp{
19+
Data: &proto.Manager{
20+
Name: "Jim",
21+
Level: proto.ManagerLevelAsString(proto.ManagerLevel_JUNIOR),
22+
},
23+
}
2324
}
2425

2526
func (m *MyManagerServer) CreateManager(ctx context.Context, req *proto.CreateManagerReq) *proto.CreateManagerResp {

gen/testdata/manager/go/proto/manager.go

Lines changed: 15 additions & 116 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/testdata/manager/go/proto/stream.go

Lines changed: 3 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)