cmd/protoc-gen-go-grpc: fix camel-casing of names in generated code

Fix a few points of divergence between the v1 and v2 generators around
when to apply camel-casing to service and method names.

Change-Id: I862f89c0995c540e4862013316d7af772e1ab0d8
Reviewed-on: https://go-review.googlesource.com/c/153658
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
This commit is contained in:
Damien Neil 2018-12-11 09:24:55 -08:00
parent 08c3cdf59f
commit 692690ff4e
2 changed files with 8 additions and 8 deletions

View File

@ -150,7 +150,7 @@ func genService(gen *protogen.Plugin, file *protogen.File, g *protogen.Generated
continue
}
g.P("{")
g.P("MethodName: ", strconv.Quote(method.GoName), ",")
g.P("MethodName: ", strconv.Quote(string(method.Desc.Name())), ",")
g.P("Handler: ", handlerNames[i], ",")
g.P("},")
}
@ -161,7 +161,7 @@ func genService(gen *protogen.Plugin, file *protogen.File, g *protogen.Generated
continue
}
g.P("{")
g.P("StreamName: ", strconv.Quote(method.GoName), ",")
g.P("StreamName: ", strconv.Quote(string(method.Desc.Name())), ",")
g.P("Handler: ", handlerNames[i], ",")
if method.Desc.IsStreamingServer() {
g.P("ServerStreams: true,")
@ -298,7 +298,7 @@ func genServerMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.Gene
g.P("if interceptor == nil { return srv.(", service.GoName, "Server).", method.GoName, "(ctx, in) }")
g.P("info := &", grpcPackage.Ident("UnaryServerInfo"), "{")
g.P("Server: srv,")
g.P("FullMethod: ", strconv.Quote(fmt.Sprintf("/%s/%s", service.Desc.FullName(), method.Desc.Name())), ",")
g.P("FullMethod: ", strconv.Quote(fmt.Sprintf("/%s/%s", service.Desc.FullName(), method.GoName)), ",")
g.P("}")
g.P("handler := func(ctx ", contextPackage.Ident("Context"), ", req interface{}) (interface{}, error) {")
g.P("return srv.(", service.GoName, "Server).", method.GoName, "(ctx, req.(*", method.InputType.GoIdent, "))")

View File

@ -167,7 +167,7 @@ func _TestService_UnaryCall_Handler(srv interface{}, ctx context.Context, dec fu
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/goproto.protoc.grpc.test_service/unary_call",
FullMethod: "/goproto.protoc.grpc.test_service/UnaryCall",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(TestServiceServer).UnaryCall(ctx, req.(*Request))
@ -253,23 +253,23 @@ var _TestService_serviceDesc = grpc.ServiceDesc{
HandlerType: (*TestServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "UnaryCall",
MethodName: "unary_call",
Handler: _TestService_UnaryCall_Handler,
},
},
Streams: []grpc.StreamDesc{
{
StreamName: "DownstreamCall",
StreamName: "downstream_call",
Handler: _TestService_DownstreamCall_Handler,
ServerStreams: true,
},
{
StreamName: "UpstreamCall",
StreamName: "upstream_call",
Handler: _TestService_UpstreamCall_Handler,
ClientStreams: true,
},
{
StreamName: "BidiCall",
StreamName: "bidi_call",
Handler: _TestService_BidiCall_Handler,
ServerStreams: true,
ClientStreams: true,