diff --git a/cmd/protoc-gen-go-grpc/grpc.go b/cmd/protoc-gen-go-grpc/grpc.go index 8091e1f7716a..159983bf5985 100644 --- a/cmd/protoc-gen-go-grpc/grpc.go +++ b/cmd/protoc-gen-go-grpc/grpc.go @@ -29,7 +29,6 @@ import ( ) const ( - errorsPackage = protogen.GoImportPath("errors") contextPackage = protogen.GoImportPath("context") grpcPackage = protogen.GoImportPath("google.golang.org/grpc") codesPackage = protogen.GoImportPath("google.golang.org/grpc/codes") @@ -136,6 +135,18 @@ func genClientMethod(gen *protogen.Plugin, g *protogen.GeneratedFile, method *pr if method.Desc.Options().(*descriptorpb.MethodOptions).GetDeprecated() { g.P(deprecationComment) } + + streamDescName := unexport(service.GoName) + method.GoName + "StreamDesc" + g.P("var ", streamDescName, " = &", grpcPackage.Ident("StreamDesc"), "{") + g.P("StreamName: ", strconv.Quote(string(method.Desc.Name())), ",") + if method.Desc.IsStreamingServer() { + g.P("ServerStreams: true,") + } + if method.Desc.IsStreamingClient() { + g.P("ClientStreams: true,") + } + g.P("}") + g.P("func (c *", unexport(service.GoName), "Client) ", clientSignature(g, method), "{") if !method.Desc.IsStreamingServer() && !method.Desc.IsStreamingClient() { g.P("out := new(", method.Output.GoIdent, ")") @@ -148,17 +159,7 @@ func genClientMethod(gen *protogen.Plugin, g *protogen.GeneratedFile, method *pr } streamType := unexport(service.GoName) + method.GoName + "Client" - g.P("streamDesc := &", grpcPackage.Ident("StreamDesc"), "{") - g.P("StreamName: ", strconv.Quote(string(method.Desc.Name())), ",") - if method.Desc.IsStreamingServer() { - g.P("ServerStreams: true,") - } - if method.Desc.IsStreamingClient() { - g.P("ClientStreams: true,") - } - g.P("}") - - g.P(`stream, err := c.cc.NewStream(ctx, streamDesc, "`, sname, `", opts...)`) + g.P(`stream, err := c.cc.NewStream(ctx, `, streamDescName, `, "`, sname, `", opts...)`) g.P("if err != nil { return nil, err }") g.P("x := &", streamType, "{stream}") if !method.Desc.IsStreamingClient() { @@ -384,12 +385,12 @@ func handlerSignature(g *protogen.GeneratedFile, method *protogen.Method) string } func unaryHandlerSignature(g *protogen.GeneratedFile) string { - return "(srv interface{}, ctx " + g.QualifiedGoIdent(contextPackage.Ident("Context")) + + return "(_ interface{}, ctx " + g.QualifiedGoIdent(contextPackage.Ident("Context")) + ", dec func(interface{}) error, interceptor " + g.QualifiedGoIdent(grpcPackage.Ident("UnaryServerInterceptor")) + ") (interface{}, error)" } func streamHandlerSignature(g *protogen.GeneratedFile) string { - return "(srv interface{}, stream " + g.QualifiedGoIdent(grpcPackage.Ident("ServerStream")) + ") error" + return "(_ interface{}, stream " + g.QualifiedGoIdent(grpcPackage.Ident("ServerStream")) + ") error" } func genMethodHandler(gen *protogen.Plugin, g *protogen.GeneratedFile, method *protogen.Method) { diff --git a/examples/features/proto/echo/echo_grpc.pb.go b/examples/features/proto/echo/echo_grpc.pb.go index c110f509c17d..a3597048577a 100644 --- a/examples/features/proto/echo/echo_grpc.pb.go +++ b/examples/features/proto/echo/echo_grpc.pb.go @@ -35,6 +35,10 @@ func NewEchoClient(cc grpc.ClientConnInterface) EchoClient { return &echoClient{cc} } +var echoUnaryEchoStreamDesc = &grpc.StreamDesc{ + StreamName: "UnaryEcho", +} + func (c *echoClient) UnaryEcho(ctx context.Context, in *EchoRequest, opts ...grpc.CallOption) (*EchoResponse, error) { out := new(EchoResponse) err := c.cc.Invoke(ctx, "/grpc.examples.echo.Echo/UnaryEcho", in, out, opts...) @@ -44,12 +48,13 @@ func (c *echoClient) UnaryEcho(ctx context.Context, in *EchoRequest, opts ...grp return out, nil } +var echoServerStreamingEchoStreamDesc = &grpc.StreamDesc{ + StreamName: "ServerStreamingEcho", + ServerStreams: true, +} + func (c *echoClient) ServerStreamingEcho(ctx context.Context, in *EchoRequest, opts ...grpc.CallOption) (Echo_ServerStreamingEchoClient, error) { - streamDesc := &grpc.StreamDesc{ - StreamName: "ServerStreamingEcho", - ServerStreams: true, - } - stream, err := c.cc.NewStream(ctx, streamDesc, "/grpc.examples.echo.Echo/ServerStreamingEcho", opts...) + stream, err := c.cc.NewStream(ctx, echoServerStreamingEchoStreamDesc, "/grpc.examples.echo.Echo/ServerStreamingEcho", opts...) if err != nil { return nil, err } @@ -80,12 +85,13 @@ func (x *echoServerStreamingEchoClient) Recv() (*EchoResponse, error) { return m, nil } +var echoClientStreamingEchoStreamDesc = &grpc.StreamDesc{ + StreamName: "ClientStreamingEcho", + ClientStreams: true, +} + func (c *echoClient) ClientStreamingEcho(ctx context.Context, opts ...grpc.CallOption) (Echo_ClientStreamingEchoClient, error) { - streamDesc := &grpc.StreamDesc{ - StreamName: "ClientStreamingEcho", - ClientStreams: true, - } - stream, err := c.cc.NewStream(ctx, streamDesc, "/grpc.examples.echo.Echo/ClientStreamingEcho", opts...) + stream, err := c.cc.NewStream(ctx, echoClientStreamingEchoStreamDesc, "/grpc.examples.echo.Echo/ClientStreamingEcho", opts...) if err != nil { return nil, err } @@ -118,13 +124,14 @@ func (x *echoClientStreamingEchoClient) CloseAndRecv() (*EchoResponse, error) { return m, nil } +var echoBidirectionalStreamingEchoStreamDesc = &grpc.StreamDesc{ + StreamName: "BidirectionalStreamingEcho", + ServerStreams: true, + ClientStreams: true, +} + func (c *echoClient) BidirectionalStreamingEcho(ctx context.Context, opts ...grpc.CallOption) (Echo_BidirectionalStreamingEchoClient, error) { - streamDesc := &grpc.StreamDesc{ - StreamName: "BidirectionalStreamingEcho", - ServerStreams: true, - ClientStreams: true, - } - stream, err := c.cc.NewStream(ctx, streamDesc, "/grpc.examples.echo.Echo/BidirectionalStreamingEcho", opts...) + stream, err := c.cc.NewStream(ctx, echoBidirectionalStreamingEchoStreamDesc, "/grpc.examples.echo.Echo/BidirectionalStreamingEcho", opts...) if err != nil { return nil, err } @@ -169,7 +176,7 @@ type EchoService struct { BidirectionalStreamingEcho func(Echo_BidirectionalStreamingEchoServer) error } -func (s *EchoService) unaryEcho(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func (s *EchoService) unaryEcho(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { if s.UnaryEcho == nil { return nil, status.Errorf(codes.Unimplemented, "method UnaryEcho not implemented") } @@ -189,7 +196,7 @@ func (s *EchoService) unaryEcho(srv interface{}, ctx context.Context, dec func(i } return interceptor(ctx, in, info, handler) } -func (s *EchoService) serverStreamingEcho(srv interface{}, stream grpc.ServerStream) error { +func (s *EchoService) serverStreamingEcho(_ interface{}, stream grpc.ServerStream) error { if s.ServerStreamingEcho == nil { return status.Errorf(codes.Unimplemented, "method ServerStreamingEcho not implemented") } @@ -199,13 +206,13 @@ func (s *EchoService) serverStreamingEcho(srv interface{}, stream grpc.ServerStr } return s.ServerStreamingEcho(m, &echoServerStreamingEchoServer{stream}) } -func (s *EchoService) clientStreamingEcho(srv interface{}, stream grpc.ServerStream) error { +func (s *EchoService) clientStreamingEcho(_ interface{}, stream grpc.ServerStream) error { if s.ClientStreamingEcho == nil { return status.Errorf(codes.Unimplemented, "method ClientStreamingEcho not implemented") } return s.ClientStreamingEcho(&echoClientStreamingEchoServer{stream}) } -func (s *EchoService) bidirectionalStreamingEcho(srv interface{}, stream grpc.ServerStream) error { +func (s *EchoService) bidirectionalStreamingEcho(_ interface{}, stream grpc.ServerStream) error { if s.BidirectionalStreamingEcho == nil { return status.Errorf(codes.Unimplemented, "method BidirectionalStreamingEcho not implemented") } @@ -307,7 +314,8 @@ func RegisterEchoService(s grpc.ServiceRegistrar, srv *EchoService) { // implemented methods of the Echo service in s. Any unimplemented // methods will result in the gRPC server returning an UNIMPLEMENTED status to the client. // This includes situations where the method handler is misspelled or has the wrong -// signature. For this reason, this function should be used with great care. +// signature. For this reason, this function should be used with great care and +// is not recommended to be used by most users. func NewEchoService(s interface{}) *EchoService { ns := &EchoService{} if h, ok := s.(interface { diff --git a/examples/features/reflection/server/main.go b/examples/features/reflection/server/main.go index 17d18e6b6bf4..1501c01f33aa 100644 --- a/examples/features/reflection/server/main.go +++ b/examples/features/reflection/server/main.go @@ -40,7 +40,7 @@ func sayHello(ctx context.Context, in *hwpb.HelloRequest) (*hwpb.HelloReply, err return &hwpb.HelloReply{Message: "Hello " + in.Name}, nil } -// unaryEcho implementes echo.Echo.UnaryEcho +// unaryEcho implements echo.Echo.UnaryEcho func unaryEcho(ctx context.Context, req *ecpb.EchoRequest) (*ecpb.EchoResponse, error) { return &ecpb.EchoResponse{Message: req.Message}, nil } diff --git a/examples/helloworld/helloworld/helloworld_grpc.pb.go b/examples/helloworld/helloworld/helloworld_grpc.pb.go index 18fcf0baff86..b45a600cead2 100644 --- a/examples/helloworld/helloworld/helloworld_grpc.pb.go +++ b/examples/helloworld/helloworld/helloworld_grpc.pb.go @@ -29,6 +29,10 @@ func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient { return &greeterClient{cc} } +var greeterSayHelloStreamDesc = &grpc.StreamDesc{ + StreamName: "SayHello", +} + func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) { out := new(HelloReply) err := c.cc.Invoke(ctx, "/helloworld.Greeter/SayHello", in, out, opts...) @@ -47,7 +51,7 @@ type GreeterService struct { SayHello func(context.Context, *HelloRequest) (*HelloReply, error) } -func (s *GreeterService) sayHello(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func (s *GreeterService) sayHello(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { if s.SayHello == nil { return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") } @@ -89,7 +93,8 @@ func RegisterGreeterService(s grpc.ServiceRegistrar, srv *GreeterService) { // implemented methods of the Greeter service in s. Any unimplemented // methods will result in the gRPC server returning an UNIMPLEMENTED status to the client. // This includes situations where the method handler is misspelled or has the wrong -// signature. For this reason, this function should be used with great care. +// signature. For this reason, this function should be used with great care and +// is not recommended to be used by most users. func NewGreeterService(s interface{}) *GreeterService { ns := &GreeterService{} if h, ok := s.(interface { diff --git a/examples/route_guide/routeguide/route_guide_grpc.pb.go b/examples/route_guide/routeguide/route_guide_grpc.pb.go index bf30c0f066d1..f9c59a7f1d0f 100644 --- a/examples/route_guide/routeguide/route_guide_grpc.pb.go +++ b/examples/route_guide/routeguide/route_guide_grpc.pb.go @@ -51,6 +51,10 @@ func NewRouteGuideClient(cc grpc.ClientConnInterface) RouteGuideClient { return &routeGuideClient{cc} } +var routeGuideGetFeatureStreamDesc = &grpc.StreamDesc{ + StreamName: "GetFeature", +} + func (c *routeGuideClient) GetFeature(ctx context.Context, in *Point, opts ...grpc.CallOption) (*Feature, error) { out := new(Feature) err := c.cc.Invoke(ctx, "/routeguide.RouteGuide/GetFeature", in, out, opts...) @@ -60,12 +64,13 @@ func (c *routeGuideClient) GetFeature(ctx context.Context, in *Point, opts ...gr return out, nil } +var routeGuideListFeaturesStreamDesc = &grpc.StreamDesc{ + StreamName: "ListFeatures", + ServerStreams: true, +} + func (c *routeGuideClient) ListFeatures(ctx context.Context, in *Rectangle, opts ...grpc.CallOption) (RouteGuide_ListFeaturesClient, error) { - streamDesc := &grpc.StreamDesc{ - StreamName: "ListFeatures", - ServerStreams: true, - } - stream, err := c.cc.NewStream(ctx, streamDesc, "/routeguide.RouteGuide/ListFeatures", opts...) + stream, err := c.cc.NewStream(ctx, routeGuideListFeaturesStreamDesc, "/routeguide.RouteGuide/ListFeatures", opts...) if err != nil { return nil, err } @@ -96,12 +101,13 @@ func (x *routeGuideListFeaturesClient) Recv() (*Feature, error) { return m, nil } +var routeGuideRecordRouteStreamDesc = &grpc.StreamDesc{ + StreamName: "RecordRoute", + ClientStreams: true, +} + func (c *routeGuideClient) RecordRoute(ctx context.Context, opts ...grpc.CallOption) (RouteGuide_RecordRouteClient, error) { - streamDesc := &grpc.StreamDesc{ - StreamName: "RecordRoute", - ClientStreams: true, - } - stream, err := c.cc.NewStream(ctx, streamDesc, "/routeguide.RouteGuide/RecordRoute", opts...) + stream, err := c.cc.NewStream(ctx, routeGuideRecordRouteStreamDesc, "/routeguide.RouteGuide/RecordRoute", opts...) if err != nil { return nil, err } @@ -134,13 +140,14 @@ func (x *routeGuideRecordRouteClient) CloseAndRecv() (*RouteSummary, error) { return m, nil } +var routeGuideRouteChatStreamDesc = &grpc.StreamDesc{ + StreamName: "RouteChat", + ServerStreams: true, + ClientStreams: true, +} + func (c *routeGuideClient) RouteChat(ctx context.Context, opts ...grpc.CallOption) (RouteGuide_RouteChatClient, error) { - streamDesc := &grpc.StreamDesc{ - StreamName: "RouteChat", - ServerStreams: true, - ClientStreams: true, - } - stream, err := c.cc.NewStream(ctx, streamDesc, "/routeguide.RouteGuide/RouteChat", opts...) + stream, err := c.cc.NewStream(ctx, routeGuideRouteChatStreamDesc, "/routeguide.RouteGuide/RouteChat", opts...) if err != nil { return nil, err } @@ -201,7 +208,7 @@ type RouteGuideService struct { RouteChat func(RouteGuide_RouteChatServer) error } -func (s *RouteGuideService) getFeature(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func (s *RouteGuideService) getFeature(_ interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { if s.GetFeature == nil { return nil, status.Errorf(codes.Unimplemented, "method GetFeature not implemented") } @@ -221,7 +228,7 @@ func (s *RouteGuideService) getFeature(srv interface{}, ctx context.Context, dec } return interceptor(ctx, in, info, handler) } -func (s *RouteGuideService) listFeatures(srv interface{}, stream grpc.ServerStream) error { +func (s *RouteGuideService) listFeatures(_ interface{}, stream grpc.ServerStream) error { if s.ListFeatures == nil { return status.Errorf(codes.Unimplemented, "method ListFeatures not implemented") } @@ -231,13 +238,13 @@ func (s *RouteGuideService) listFeatures(srv interface{}, stream grpc.ServerStre } return s.ListFeatures(m, &routeGuideListFeaturesServer{stream}) } -func (s *RouteGuideService) recordRoute(srv interface{}, stream grpc.ServerStream) error { +func (s *RouteGuideService) recordRoute(_ interface{}, stream grpc.ServerStream) error { if s.RecordRoute == nil { return status.Errorf(codes.Unimplemented, "method RecordRoute not implemented") } return s.RecordRoute(&routeGuideRecordRouteServer{stream}) } -func (s *RouteGuideService) routeChat(srv interface{}, stream grpc.ServerStream) error { +func (s *RouteGuideService) routeChat(_ interface{}, stream grpc.ServerStream) error { if s.RouteChat == nil { return status.Errorf(codes.Unimplemented, "method RouteChat not implemented") } @@ -339,7 +346,8 @@ func RegisterRouteGuideService(s grpc.ServiceRegistrar, srv *RouteGuideService) // implemented methods of the RouteGuide service in s. Any unimplemented // methods will result in the gRPC server returning an UNIMPLEMENTED status to the client. // This includes situations where the method handler is misspelled or has the wrong -// signature. For this reason, this function should be used with great care. +// signature. For this reason, this function should be used with great care and +// is not recommended to be used by most users. func NewRouteGuideService(s interface{}) *RouteGuideService { ns := &RouteGuideService{} if h, ok := s.(interface { diff --git a/go.mod b/go.mod index db8ee9dba4b7..31f2b01f64e8 100644 --- a/go.mod +++ b/go.mod @@ -6,11 +6,10 @@ require ( github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f github.com/envoyproxy/go-control-plane v0.9.4 github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b - github.com/golang/protobuf v1.4.2 + github.com/golang/protobuf v1.3.3 github.com/google/go-cmp v0.4.0 golang.org/x/net v0.0.0-20190311183353-d8887717615a golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a - google.golang.org/genproto v0.0.0-20200624020401-64a14ca9d1ad - google.golang.org/grpc/examples v0.0.0-20200811135751-6aaac03d175a // indirect + google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 ) diff --git a/go.sum b/go.sum index 84db8d539715..be8078eace22 100644 --- a/go.sum +++ b/go.sum @@ -8,7 +8,6 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f h1:WBZRG4aNOuI15bLRrCgN8fCq8E5Xuty6jGbmSNEvSsU= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4 h1:rEvIZUSZ3fx39WIi3JkQqQBitGwpELBIYWeBVh6wn+E= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0 h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A= @@ -22,18 +21,8 @@ github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.3 h1:gyjaxf+svBWX08ZjK86iN9geUJF0H6gp2IRKX6Nf6/I= github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -71,26 +60,9 @@ google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 h1:gSJIx1SDwno+2ElGhA4+qG2zF97qiUzTM+rQ0klBOcE= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200624020401-64a14ca9d1ad h1:uAwc13+y0Y8QZLTYhLCu6lHhnG99ecQU5FYTj8zxAng= -google.golang.org/genproto v0.0.0-20200624020401-64a14ca9d1ad/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc/examples v0.0.0-20200811135751-6aaac03d175a h1:F2Kiik6O79Y6KDMfGyu0VCuf2vBL94YXYgpcKtKxc/8= -google.golang.org/grpc/examples v0.0.0-20200811135751-6aaac03d175a/go.mod h1:TGiSRL2BBv2WqzfsFNWYp/pkWdtf5kbZS/DQ9Ee3mWk= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0 h1:UhZDfRO8JRQru4/+LlLE0BRKGF8L+PICnvYZmx/fEGA= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc h1:/hemPrYIhOhy8zYrNj+069zDB68us2sMGsfkFJO0iZs= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= diff --git a/server.go b/server.go index 12dc35657aea..e8769f87d00c 100644 --- a/server.go +++ b/server.go @@ -554,8 +554,8 @@ type ServiceRegistrar interface { // RegisterService registers a service and its implementation to the gRPC // server. It is called from the IDL generated code. This must be called before -// invoking Serve. If ss is non-nil, its type is checked to ensure it -// implements sd.HandlerType. +// invoking Serve. If ss is non-nil (for legacy code), its type is checked to +// ensure it implements sd.HandlerType. func (s *Server) RegisterService(sd *ServiceDesc, ss interface{}) { if ss != nil { ht := reflect.TypeOf(sd.HandlerType).Elem()