Skip to content

Commit 0e63a05

Browse files
committed
update
1 parent f0338ec commit 0e63a05

File tree

5 files changed

+24
-94
lines changed

5 files changed

+24
-94
lines changed

cgrpc/protoc-gen-go-cgrpc/cgrpc.go

+7-28
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ func generateFile(gen *protogen.Plugin, file *protogen.File) *protogen.Generated
3636
count := 0
3737
for _, method := range service.Methods {
3838
mop := method.Desc.Options().(*descriptorpb.MethodOptions)
39-
if mop.GetDeprecated() {
40-
continue
41-
}
42-
if !proto.HasExtension(mop, pbex.E_Method) {
39+
if mop.GetDeprecated() || !proto.HasExtension(mop, pbex.E_Method) {
4340
continue
4441
}
4542
emethod := proto.GetExtension(mop, pbex.E_Method).([]string)
@@ -87,10 +84,7 @@ func genService(file *protogen.File, s *protogen.Service, g *protogen.GeneratedF
8784
func genPath(file *protogen.File, service *protogen.Service, g *protogen.GeneratedFile) {
8885
for _, method := range service.Methods {
8986
mop := method.Desc.Options().(*descriptorpb.MethodOptions)
90-
if mop.GetDeprecated() {
91-
continue
92-
}
93-
if !proto.HasExtension(mop, pbex.E_Method) {
87+
if mop.GetDeprecated() || !proto.HasExtension(mop, pbex.E_Method) {
9488
continue
9589
}
9690
emethod := proto.GetExtension(mop, pbex.E_Method).([]string)
@@ -117,10 +111,7 @@ func genServer(file *protogen.File, service *protogen.Service, g *protogen.Gener
117111
g.P("type ", serverName, " interface {")
118112
for _, method := range service.Methods {
119113
mop := method.Desc.Options().(*descriptorpb.MethodOptions)
120-
if mop.GetDeprecated() {
121-
continue
122-
}
123-
if !proto.HasExtension(mop, pbex.E_Method) {
114+
if mop.GetDeprecated() || !proto.HasExtension(mop, pbex.E_Method) {
124115
continue
125116
}
126117
emethod := proto.GetExtension(mop, pbex.E_Method).([]string)
@@ -143,10 +134,7 @@ func genServer(file *protogen.File, service *protogen.Service, g *protogen.Gener
143134
// Server handler
144135
for _, method := range service.Methods {
145136
mop := method.Desc.Options().(*descriptorpb.MethodOptions)
146-
if mop.GetDeprecated() {
147-
continue
148-
}
149-
if !proto.HasExtension(mop, pbex.E_Method) {
137+
if mop.GetDeprecated() || !proto.HasExtension(mop, pbex.E_Method) {
150138
continue
151139
}
152140
emethod := proto.GetExtension(mop, pbex.E_Method).([]string)
@@ -200,10 +188,7 @@ func genServer(file *protogen.File, service *protogen.Service, g *protogen.Gener
200188
g.P("_=allmids")
201189
for _, method := range service.Methods {
202190
mop := method.Desc.Options().(*descriptorpb.MethodOptions)
203-
if mop.GetDeprecated() {
204-
continue
205-
}
206-
if !proto.HasExtension(mop, pbex.E_Method) {
191+
if mop.GetDeprecated() || !proto.HasExtension(mop, pbex.E_Method) {
207192
continue
208193
}
209194
emethod := proto.GetExtension(mop, pbex.E_Method).([]string)
@@ -256,10 +241,7 @@ func genClient(file *protogen.File, service *protogen.Service, g *protogen.Gener
256241
g.P("type ", clientName, " interface {")
257242
for _, method := range service.Methods {
258243
mop := method.Desc.Options().(*descriptorpb.MethodOptions)
259-
if mop.GetDeprecated() {
260-
continue
261-
}
262-
if !proto.HasExtension(mop, pbex.E_Method) {
244+
if mop.GetDeprecated() || !proto.HasExtension(mop, pbex.E_Method) {
263245
continue
264246
}
265247
emethod := proto.GetExtension(mop, pbex.E_Method).([]string)
@@ -289,10 +271,7 @@ func genClient(file *protogen.File, service *protogen.Service, g *protogen.Gener
289271
// Client handler
290272
for _, method := range service.Methods {
291273
mop := method.Desc.Options().(*descriptorpb.MethodOptions)
292-
if mop.GetDeprecated() {
293-
continue
294-
}
295-
if !proto.HasExtension(mop, pbex.E_Method) {
274+
if mop.GetDeprecated() || !proto.HasExtension(mop, pbex.E_Method) {
296275
continue
297276
}
298277
emethod := proto.GetExtension(mop, pbex.E_Method).([]string)

cgrpc/protoc-gen-go-cgrpc/main.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@ func main() {
4242
}
4343
for _, m := range s.Methods {
4444
mop := m.Desc.Options().(*descriptorpb.MethodOptions)
45-
if mop.GetDeprecated() {
46-
continue
47-
}
48-
if !proto.HasExtension(mop, pbex.E_Method) {
45+
if mop.GetDeprecated() || !proto.HasExtension(mop, pbex.E_Method) {
4946
continue
5047
}
5148
emethod := proto.GetExtension(mop, pbex.E_Method).([]string)

crpc/protoc-gen-go-crpc/crpc.go

+7-28
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ func generateFile(gen *protogen.Plugin, file *protogen.File) *protogen.Generated
3838
count := 0
3939
for _, method := range service.Methods {
4040
mop := method.Desc.Options().(*descriptorpb.MethodOptions)
41-
if mop.GetDeprecated() {
42-
continue
43-
}
44-
if !proto.HasExtension(mop, pbex.E_Method) {
41+
if mop.GetDeprecated() || !proto.HasExtension(mop, pbex.E_Method) {
4542
continue
4643
}
4744
emethod := proto.GetExtension(mop, pbex.E_Method).([]string)
@@ -89,10 +86,7 @@ func genService(file *protogen.File, s *protogen.Service, g *protogen.GeneratedF
8986
func genPath(file *protogen.File, service *protogen.Service, g *protogen.GeneratedFile) {
9087
for _, method := range service.Methods {
9188
mop := method.Desc.Options().(*descriptorpb.MethodOptions)
92-
if mop.GetDeprecated() {
93-
continue
94-
}
95-
if !proto.HasExtension(mop, pbex.E_Method) {
89+
if mop.GetDeprecated() || !proto.HasExtension(mop, pbex.E_Method) {
9690
continue
9791
}
9892
emethod := proto.GetExtension(mop, pbex.E_Method).([]string)
@@ -119,10 +113,7 @@ func genServer(file *protogen.File, service *protogen.Service, g *protogen.Gener
119113
g.P("type ", serverName, " interface {")
120114
for _, method := range service.Methods {
121115
mop := method.Desc.Options().(*descriptorpb.MethodOptions)
122-
if mop.GetDeprecated() {
123-
continue
124-
}
125-
if !proto.HasExtension(mop, pbex.E_Method) {
116+
if mop.GetDeprecated() || !proto.HasExtension(mop, pbex.E_Method) {
126117
continue
127118
}
128119
emethod := proto.GetExtension(mop, pbex.E_Method).([]string)
@@ -145,10 +136,7 @@ func genServer(file *protogen.File, service *protogen.Service, g *protogen.Gener
145136
// Server handler
146137
for _, method := range service.Methods {
147138
mop := method.Desc.Options().(*descriptorpb.MethodOptions)
148-
if mop.GetDeprecated() {
149-
continue
150-
}
151-
if !proto.HasExtension(mop, pbex.E_Method) {
139+
if mop.GetDeprecated() || !proto.HasExtension(mop, pbex.E_Method) {
152140
continue
153141
}
154142
emethod := proto.GetExtension(mop, pbex.E_Method).([]string)
@@ -226,10 +214,7 @@ func genServer(file *protogen.File, service *protogen.Service, g *protogen.Gener
226214
g.P("_=allmids")
227215
for _, method := range service.Methods {
228216
mop := method.Desc.Options().(*descriptorpb.MethodOptions)
229-
if mop.GetDeprecated() {
230-
continue
231-
}
232-
if !proto.HasExtension(mop, pbex.E_Method) {
217+
if mop.GetDeprecated() || !proto.HasExtension(mop, pbex.E_Method) {
233218
continue
234219
}
235220
emethod := proto.GetExtension(mop, pbex.E_Method).([]string)
@@ -282,10 +267,7 @@ func genClient(file *protogen.File, service *protogen.Service, g *protogen.Gener
282267
g.P("type ", clientName, " interface {")
283268
for _, method := range service.Methods {
284269
mop := method.Desc.Options().(*descriptorpb.MethodOptions)
285-
if mop.GetDeprecated() {
286-
continue
287-
}
288-
if !proto.HasExtension(mop, pbex.E_Method) {
270+
if mop.GetDeprecated() || !proto.HasExtension(mop, pbex.E_Method) {
289271
continue
290272
}
291273
emethod := proto.GetExtension(mop, pbex.E_Method).([]string)
@@ -315,10 +297,7 @@ func genClient(file *protogen.File, service *protogen.Service, g *protogen.Gener
315297
// Client handler
316298
for _, method := range service.Methods {
317299
mop := method.Desc.Options().(*descriptorpb.MethodOptions)
318-
if mop.GetDeprecated() {
319-
continue
320-
}
321-
if !proto.HasExtension(mop, pbex.E_Method) {
300+
if mop.GetDeprecated() || !proto.HasExtension(mop, pbex.E_Method) {
322301
continue
323302
}
324303
emethod := proto.GetExtension(mop, pbex.E_Method).([]string)

crpc/protoc-gen-go-crpc/main.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@ func main() {
4242
}
4343
for _, m := range s.Methods {
4444
mop := m.Desc.Options().(*descriptorpb.MethodOptions)
45-
if mop.GetDeprecated() {
46-
continue
47-
}
48-
if !proto.HasExtension(mop, pbex.E_Method) {
45+
if mop.GetDeprecated() || !proto.HasExtension(mop, pbex.E_Method) {
4946
continue
5047
}
5148
emethod := proto.GetExtension(mop, pbex.E_Method).([]string)

web/protoc-gen-go-web/web.go

+8-30
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package main
22

33
import (
44
"fmt"
5-
"net/http"
65
"strconv"
76
"strings"
87

@@ -51,10 +50,7 @@ func generateFile(gen *protogen.Plugin, file *protogen.File) *protogen.Generated
5150
count := 0
5251
for _, method := range service.Methods {
5352
mop := method.Desc.Options().(*descriptorpb.MethodOptions)
54-
if mop.GetDeprecated() {
55-
continue
56-
}
57-
if !proto.HasExtension(mop, pbex.E_Method) {
53+
if mop.GetDeprecated() || !proto.HasExtension(mop, pbex.E_Method) {
5854
continue
5955
}
6056
emethod := proto.GetExtension(mop, pbex.E_Method).([]string)
@@ -101,10 +97,7 @@ func genService(file *protogen.File, s *protogen.Service, g *protogen.GeneratedF
10197
func genPath(file *protogen.File, service *protogen.Service, g *protogen.GeneratedFile) {
10298
for _, method := range service.Methods {
10399
mop := method.Desc.Options().(*descriptorpb.MethodOptions)
104-
if mop.GetDeprecated() {
105-
continue
106-
}
107-
if !proto.HasExtension(mop, pbex.E_Method) {
100+
if mop.GetDeprecated() || !proto.HasExtension(mop, pbex.E_Method) {
108101
continue
109102
}
110103
emethod := proto.GetExtension(mop, pbex.E_Method).([]string)
@@ -132,10 +125,7 @@ func genServer(file *protogen.File, service *protogen.Service, g *protogen.Gener
132125
g.P("type ", serverName, " interface {")
133126
for _, method := range service.Methods {
134127
mop := method.Desc.Options().(*descriptorpb.MethodOptions)
135-
if mop.GetDeprecated() {
136-
continue
137-
}
138-
if !proto.HasExtension(mop, pbex.E_Method) {
128+
if mop.GetDeprecated() || !proto.HasExtension(mop, pbex.E_Method) {
139129
continue
140130
}
141131
emethod := proto.GetExtension(mop, pbex.E_Method).([]string)
@@ -159,10 +149,7 @@ func genServer(file *protogen.File, service *protogen.Service, g *protogen.Gener
159149
// Server handler
160150
for _, method := range service.Methods {
161151
mop := method.Desc.Options().(*descriptorpb.MethodOptions)
162-
if mop.GetDeprecated() {
163-
continue
164-
}
165-
if !proto.HasExtension(mop, pbex.E_Method) {
152+
if mop.GetDeprecated() || !proto.HasExtension(mop, pbex.E_Method) {
166153
continue
167154
}
168155
emethod := proto.GetExtension(mop, pbex.E_Method).([]string)
@@ -745,10 +732,7 @@ func genServer(file *protogen.File, service *protogen.Service, g *protogen.Gener
745732
g.P("_=allmids")
746733
for _, method := range service.Methods {
747734
mop := method.Desc.Options().(*descriptorpb.MethodOptions)
748-
if mop.GetDeprecated() {
749-
continue
750-
}
751-
if !proto.HasExtension(mop, pbex.E_Method) {
735+
if mop.GetDeprecated() || !proto.HasExtension(mop, pbex.E_Method) {
752736
continue
753737
}
754738
emethod := proto.GetExtension(mop, pbex.E_Method).([]string)
@@ -826,10 +810,7 @@ func genClient(file *protogen.File, service *protogen.Service, g *protogen.Gener
826810
g.P("type ", clientName, " interface {")
827811
for _, method := range service.Methods {
828812
mop := method.Desc.Options().(*descriptorpb.MethodOptions)
829-
if mop.GetDeprecated() {
830-
continue
831-
}
832-
if !proto.HasExtension(mop, pbex.E_Method) {
813+
if mop.GetDeprecated() || !proto.HasExtension(mop, pbex.E_Method) {
833814
continue
834815
}
835816
emethod := proto.GetExtension(mop, pbex.E_Method).([]string)
@@ -864,10 +845,7 @@ func genClient(file *protogen.File, service *protogen.Service, g *protogen.Gener
864845
// Client handler
865846
for _, method := range service.Methods {
866847
mop := method.Desc.Options().(*descriptorpb.MethodOptions)
867-
if mop.GetDeprecated() {
868-
continue
869-
}
870-
if !proto.HasExtension(mop, pbex.E_Method) {
848+
if mop.GetDeprecated() || !proto.HasExtension(mop, pbex.E_Method) {
871849
continue
872850
}
873851
emethod := proto.GetExtension(mop, pbex.E_Method).([]string)
@@ -896,7 +874,7 @@ func genClient(file *protogen.File, service *protogen.Service, g *protogen.Gener
896874
g.P("header = make(", g.QualifiedGoIdent(httpPackage.Ident("Header")), ")")
897875
g.P("}")
898876

899-
if need == http.MethodGet || need == http.MethodDelete {
877+
if need == "GET" || need == "DELETE" {
900878
g.P("header.Set(", strconv.Quote("Content-Type"), ",", strconv.Quote("application/x-www-form-urlencoded"), ")")
901879
g.P("header.Set(", strconv.Quote("Accept"), ",", strconv.Quote("application/x-protobuf"), ")")
902880
g.P("query :=", g.QualifiedGoIdent(poolPackage.Ident("GetPool")), "().Get(0)")

0 commit comments

Comments
 (0)