Skip to content

Commit e9d2207

Browse files
lvan100lianghuan
authored andcommitted
111
1 parent 328aaab commit e9d2207

File tree

4 files changed

+12
-19
lines changed

4 files changed

+12
-19
lines changed

gen/generator/golang/spec.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,6 @@ func (t *Type) QueryCount() int {
100100
return count
101101
}
102102

103-
// ValidateCount returns the number of fields in the struct that have validation expressions
104-
func (t *Type) ValidateCount() int {
105-
var count int
106-
for _, f := range t.Fields {
107-
if f.Validate != nil {
108-
count++
109-
}
110-
}
111-
return count
112-
}
113-
114103
// RPC represents a single remote procedure call with HTTP metadata.
115104
type RPC struct {
116105
Name string // Method name

gen/generator/golang/type.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,17 @@ const {{$c.Name}} {{$c.Type}} = {{$c.Value}}
202202
203203
// Binding extracts non-body values (path, query) from *http.Request.
204204
func (x *{{$s.Name}}) Binding(r *http.Request) error {
205-
return Binding(r, []BindingField {
206-
{{- range $f := $s.Fields}}
207-
{{- if $f.Binding}}
208-
{"{{$s.Name}}.{{$f.Name}}", "{{$f.Binding.From}}", "{{$f.Binding.Name}}", &x.{{$f.Name}}},
205+
{{- if $s.BindingCount}}
206+
return Binding(r, []BindingField {
207+
{{- range $f := $s.Fields}}
208+
{{- if $f.Binding}}
209+
{"{{$s.Name}}.{{$f.Name}}", "{{$f.Binding.From}}", "{{$f.Binding.Name}}", &x.{{$f.Name}}},
210+
{{- end}}
209211
{{- end}}
210-
{{- end}}
211-
})
212+
})
213+
{{- else}}
214+
return nil
215+
{{- end}}
212216
}
213217
{{end}}
214218

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

Lines changed: 1 addition & 1 deletion
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: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)