cmd/protoc-gen-go-grpc: remove
Change-Id: I8bc67d71a6431807f0a6975dfc416cca56a28c7f
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/220355
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/cmd/protoc-gen-go-grpc/internal_gengogrpc/grpc.go b/cmd/protoc-gen-go-grpc/internal_gengogrpc/grpc.go
deleted file mode 100644
index 06be097..0000000
--- a/cmd/protoc-gen-go-grpc/internal_gengogrpc/grpc.go
+++ /dev/null
@@ -1,398 +0,0 @@
-// Copyright 2018 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Package internal_gengogrpc is internal to the protobuf module.
-package internal_gengogrpc
-
-import (
- "fmt"
- "strconv"
- "strings"
-
- "google.golang.org/protobuf/compiler/protogen"
-
- "google.golang.org/protobuf/types/descriptorpb"
-)
-
-const (
- contextPackage = protogen.GoImportPath("context")
- grpcPackage = protogen.GoImportPath("google.golang.org/grpc")
- codesPackage = protogen.GoImportPath("google.golang.org/grpc/codes")
- statusPackage = protogen.GoImportPath("google.golang.org/grpc/status")
-)
-
-// GenerateFile generates a _grpc.pb.go file containing gRPC service definitions.
-func GenerateFile(gen *protogen.Plugin, file *protogen.File) *protogen.GeneratedFile {
- if len(file.Services) == 0 {
- return nil
- }
- filename := file.GeneratedFilenamePrefix + "_grpc.pb.go"
- g := gen.NewGeneratedFile(filename, file.GoImportPath)
- g.P("// Code generated by protoc-gen-go-grpc. DO NOT EDIT.")
- g.P()
- g.P("package ", file.GoPackageName)
- g.P()
- GenerateFileContent(gen, file, g)
- return g
-}
-
-// GenerateFileContent generates the gRPC service definitions, excluding the package statement.
-func GenerateFileContent(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile) {
- if len(file.Services) == 0 {
- return
- }
-
- // TODO: Remove this. We don't need to include these references any more.
- g.P("// Reference imports to suppress errors if they are not otherwise used.")
- g.P("var _ ", contextPackage.Ident("Context"))
- g.P("var _ ", grpcPackage.Ident("ClientConnInterface"))
- g.P()
-
- g.P("// This is a compile-time assertion to ensure that this generated file")
- g.P("// is compatible with the grpc package it is being compiled against.")
- g.P("const _ = ", grpcPackage.Ident("SupportPackageIsVersion6"))
- g.P()
- for _, service := range file.Services {
- genService(gen, file, g, service)
- }
-}
-
-func genService(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, service *protogen.Service) {
- clientName := service.GoName + "Client"
-
- g.P("// ", clientName, " is the client API for ", service.GoName, " service.")
- g.P("//")
- g.P("// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.")
-
- // Client interface.
- if service.Desc.Options().(*descriptorpb.ServiceOptions).GetDeprecated() {
- g.P("//")
- g.P(deprecationComment)
- }
- g.Annotate(clientName, service.Location)
- g.P("type ", clientName, " interface {")
- for _, method := range service.Methods {
- g.Annotate(clientName+"."+method.GoName, method.Location)
- if method.Desc.Options().(*descriptorpb.MethodOptions).GetDeprecated() {
- g.P(deprecationComment)
- }
- g.P(method.Comments.Leading,
- clientSignature(g, method))
- }
- g.P("}")
- g.P()
-
- // Client structure.
- g.P("type ", unexport(clientName), " struct {")
- g.P("cc ", grpcPackage.Ident("ClientConnInterface"))
- g.P("}")
- g.P()
-
- // NewClient factory.
- if service.Desc.Options().(*descriptorpb.ServiceOptions).GetDeprecated() {
- g.P(deprecationComment)
- }
- g.P("func New", clientName, " (cc ", grpcPackage.Ident("ClientConnInterface"), ") ", clientName, " {")
- g.P("return &", unexport(clientName), "{cc}")
- g.P("}")
- g.P()
-
- var methodIndex, streamIndex int
- // Client method implementations.
- for _, method := range service.Methods {
- if !method.Desc.IsStreamingServer() && !method.Desc.IsStreamingClient() {
- // Unary RPC method
- genClientMethod(gen, file, g, method, methodIndex)
- methodIndex++
- } else {
- // Streaming RPC method
- genClientMethod(gen, file, g, method, streamIndex)
- streamIndex++
- }
- }
-
- // Server interface.
- serverType := service.GoName + "Server"
- g.P("// ", serverType, " is the server API for ", service.GoName, " service.")
- if service.Desc.Options().(*descriptorpb.ServiceOptions).GetDeprecated() {
- g.P("//")
- g.P(deprecationComment)
- }
- g.Annotate(serverType, service.Location)
- g.P("type ", serverType, " interface {")
- for _, method := range service.Methods {
- g.Annotate(serverType+"."+method.GoName, method.Location)
- if method.Desc.Options().(*descriptorpb.MethodOptions).GetDeprecated() {
- g.P(deprecationComment)
- }
- g.P(method.Comments.Leading,
- serverSignature(g, method))
- }
- g.P("}")
- g.P()
-
- // Server Unimplemented struct for forward compatibility.
- g.P("// Unimplemented", serverType, " can be embedded to have forward compatible implementations.")
- g.P("type Unimplemented", serverType, " struct {")
- g.P("}")
- g.P()
- for _, method := range service.Methods {
- nilArg := ""
- if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
- nilArg = "nil,"
- }
- g.P("func (*Unimplemented", serverType, ") ", serverSignature(g, method), "{")
- g.P("return ", nilArg, statusPackage.Ident("Errorf"), "(", codesPackage.Ident("Unimplemented"), `, "method `, method.GoName, ` not implemented")`)
- g.P("}")
- }
- g.P()
-
- // Server registration.
- if service.Desc.Options().(*descriptorpb.ServiceOptions).GetDeprecated() {
- g.P(deprecationComment)
- }
- serviceDescVar := "_" + service.GoName + "_serviceDesc"
- g.P("func Register", service.GoName, "Server(s *", grpcPackage.Ident("Server"), ", srv ", serverType, ") {")
- g.P("s.RegisterService(&", serviceDescVar, `, srv)`)
- g.P("}")
- g.P()
-
- // Server handler implementations.
- var handlerNames []string
- for _, method := range service.Methods {
- hname := genServerMethod(gen, file, g, method)
- handlerNames = append(handlerNames, hname)
- }
-
- // Service descriptor.
- g.P("var ", serviceDescVar, " = ", grpcPackage.Ident("ServiceDesc"), " {")
- g.P("ServiceName: ", strconv.Quote(string(service.Desc.FullName())), ",")
- g.P("HandlerType: (*", serverType, ")(nil),")
- g.P("Methods: []", grpcPackage.Ident("MethodDesc"), "{")
- for i, method := range service.Methods {
- if method.Desc.IsStreamingClient() || method.Desc.IsStreamingServer() {
- continue
- }
- g.P("{")
- g.P("MethodName: ", strconv.Quote(string(method.Desc.Name())), ",")
- g.P("Handler: ", handlerNames[i], ",")
- g.P("},")
- }
- g.P("},")
- g.P("Streams: []", grpcPackage.Ident("StreamDesc"), "{")
- for i, method := range service.Methods {
- if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
- continue
- }
- g.P("{")
- g.P("StreamName: ", strconv.Quote(string(method.Desc.Name())), ",")
- g.P("Handler: ", handlerNames[i], ",")
- if method.Desc.IsStreamingServer() {
- g.P("ServerStreams: true,")
- }
- if method.Desc.IsStreamingClient() {
- g.P("ClientStreams: true,")
- }
- g.P("},")
- }
- g.P("},")
- g.P("Metadata: \"", file.Desc.Path(), "\",")
- g.P("}")
- g.P()
-}
-
-func clientSignature(g *protogen.GeneratedFile, method *protogen.Method) string {
- s := method.GoName + "(ctx " + g.QualifiedGoIdent(contextPackage.Ident("Context"))
- if !method.Desc.IsStreamingClient() {
- s += ", in *" + g.QualifiedGoIdent(method.Input.GoIdent)
- }
- s += ", opts ..." + g.QualifiedGoIdent(grpcPackage.Ident("CallOption")) + ") ("
- if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
- s += "*" + g.QualifiedGoIdent(method.Output.GoIdent)
- } else {
- s += method.Parent.GoName + "_" + method.GoName + "Client"
- }
- s += ", error)"
- return s
-}
-
-func genClientMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, method *protogen.Method, index int) {
- service := method.Parent
- sname := fmt.Sprintf("/%s/%s", service.Desc.FullName(), method.Desc.Name())
-
- if method.Desc.Options().(*descriptorpb.MethodOptions).GetDeprecated() {
- g.P(deprecationComment)
- }
- 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, ")")
- g.P(`err := c.cc.Invoke(ctx, "`, sname, `", in, out, opts...)`)
- g.P("if err != nil { return nil, err }")
- g.P("return out, nil")
- g.P("}")
- g.P()
- return
- }
- streamType := unexport(service.GoName) + method.GoName + "Client"
- serviceDescVar := "_" + service.GoName + "_serviceDesc"
- g.P("stream, err := c.cc.NewStream(ctx, &", serviceDescVar, ".Streams[", index, `], "`, sname, `", opts...)`)
- g.P("if err != nil { return nil, err }")
- g.P("x := &", streamType, "{stream}")
- if !method.Desc.IsStreamingClient() {
- g.P("if err := x.ClientStream.SendMsg(in); err != nil { return nil, err }")
- g.P("if err := x.ClientStream.CloseSend(); err != nil { return nil, err }")
- }
- g.P("return x, nil")
- g.P("}")
- g.P()
-
- genSend := method.Desc.IsStreamingClient()
- genRecv := method.Desc.IsStreamingServer()
- genCloseAndRecv := !method.Desc.IsStreamingServer()
-
- // Stream auxiliary types and methods.
- g.P("type ", service.GoName, "_", method.GoName, "Client interface {")
- if genSend {
- g.P("Send(*", method.Input.GoIdent, ") error")
- }
- if genRecv {
- g.P("Recv() (*", method.Output.GoIdent, ", error)")
- }
- if genCloseAndRecv {
- g.P("CloseAndRecv() (*", method.Output.GoIdent, ", error)")
- }
- g.P(grpcPackage.Ident("ClientStream"))
- g.P("}")
- g.P()
-
- g.P("type ", streamType, " struct {")
- g.P(grpcPackage.Ident("ClientStream"))
- g.P("}")
- g.P()
-
- if genSend {
- g.P("func (x *", streamType, ") Send(m *", method.Input.GoIdent, ") error {")
- g.P("return x.ClientStream.SendMsg(m)")
- g.P("}")
- g.P()
- }
- if genRecv {
- g.P("func (x *", streamType, ") Recv() (*", method.Output.GoIdent, ", error) {")
- g.P("m := new(", method.Output.GoIdent, ")")
- g.P("if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err }")
- g.P("return m, nil")
- g.P("}")
- g.P()
- }
- if genCloseAndRecv {
- g.P("func (x *", streamType, ") CloseAndRecv() (*", method.Output.GoIdent, ", error) {")
- g.P("if err := x.ClientStream.CloseSend(); err != nil { return nil, err }")
- g.P("m := new(", method.Output.GoIdent, ")")
- g.P("if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err }")
- g.P("return m, nil")
- g.P("}")
- g.P()
- }
-}
-
-func serverSignature(g *protogen.GeneratedFile, method *protogen.Method) string {
- var reqArgs []string
- ret := "error"
- if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
- reqArgs = append(reqArgs, g.QualifiedGoIdent(contextPackage.Ident("Context")))
- ret = "(*" + g.QualifiedGoIdent(method.Output.GoIdent) + ", error)"
- }
- if !method.Desc.IsStreamingClient() {
- reqArgs = append(reqArgs, "*"+g.QualifiedGoIdent(method.Input.GoIdent))
- }
- if method.Desc.IsStreamingClient() || method.Desc.IsStreamingServer() {
- reqArgs = append(reqArgs, method.Parent.GoName+"_"+method.GoName+"Server")
- }
- return method.GoName + "(" + strings.Join(reqArgs, ", ") + ") " + ret
-}
-
-func genServerMethod(gen *protogen.Plugin, file *protogen.File, g *protogen.GeneratedFile, method *protogen.Method) string {
- service := method.Parent
- hname := fmt.Sprintf("_%s_%s_Handler", service.GoName, method.GoName)
-
- if !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() {
- g.P("func ", hname, "(srv interface{}, ctx ", contextPackage.Ident("Context"), ", dec func(interface{}) error, interceptor ", grpcPackage.Ident("UnaryServerInterceptor"), ") (interface{}, error) {")
- g.P("in := new(", method.Input.GoIdent, ")")
- g.P("if err := dec(in); err != nil { return nil, err }")
- 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.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.Input.GoIdent, "))")
- g.P("}")
- g.P("return interceptor(ctx, in, info, handler)")
- g.P("}")
- g.P()
- return hname
- }
- streamType := unexport(service.GoName) + method.GoName + "Server"
- g.P("func ", hname, "(srv interface{}, stream ", grpcPackage.Ident("ServerStream"), ") error {")
- if !method.Desc.IsStreamingClient() {
- g.P("m := new(", method.Input.GoIdent, ")")
- g.P("if err := stream.RecvMsg(m); err != nil { return err }")
- g.P("return srv.(", service.GoName, "Server).", method.GoName, "(m, &", streamType, "{stream})")
- } else {
- g.P("return srv.(", service.GoName, "Server).", method.GoName, "(&", streamType, "{stream})")
- }
- g.P("}")
- g.P()
-
- genSend := method.Desc.IsStreamingServer()
- genSendAndClose := !method.Desc.IsStreamingServer()
- genRecv := method.Desc.IsStreamingClient()
-
- // Stream auxiliary types and methods.
- g.P("type ", service.GoName, "_", method.GoName, "Server interface {")
- if genSend {
- g.P("Send(*", method.Output.GoIdent, ") error")
- }
- if genSendAndClose {
- g.P("SendAndClose(*", method.Output.GoIdent, ") error")
- }
- if genRecv {
- g.P("Recv() (*", method.Input.GoIdent, ", error)")
- }
- g.P(grpcPackage.Ident("ServerStream"))
- g.P("}")
- g.P()
-
- g.P("type ", streamType, " struct {")
- g.P(grpcPackage.Ident("ServerStream"))
- g.P("}")
- g.P()
-
- if genSend {
- g.P("func (x *", streamType, ") Send(m *", method.Output.GoIdent, ") error {")
- g.P("return x.ServerStream.SendMsg(m)")
- g.P("}")
- g.P()
- }
- if genSendAndClose {
- g.P("func (x *", streamType, ") SendAndClose(m *", method.Output.GoIdent, ") error {")
- g.P("return x.ServerStream.SendMsg(m)")
- g.P("}")
- g.P()
- }
- if genRecv {
- g.P("func (x *", streamType, ") Recv() (*", method.Input.GoIdent, ", error) {")
- g.P("m := new(", method.Input.GoIdent, ")")
- g.P("if err := x.ServerStream.RecvMsg(m); err != nil { return nil, err }")
- g.P("return m, nil")
- g.P("}")
- g.P()
- }
-
- return hname
-}
-
-const deprecationComment = "// Deprecated: Do not use."
-
-func unexport(s string) string { return strings.ToLower(s[:1]) + s[1:] }
diff --git a/cmd/protoc-gen-go-grpc/main.go b/cmd/protoc-gen-go-grpc/main.go
deleted file mode 100644
index 9cfc159..0000000
--- a/cmd/protoc-gen-go-grpc/main.go
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2018 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// The protoc-gen-go-grpc binary is a protoc plugin to generate Go gRPC
-// service definitions.
-package main
-
-import (
- "google.golang.org/protobuf/cmd/protoc-gen-go-grpc/internal_gengogrpc"
- "google.golang.org/protobuf/compiler/protogen"
-)
-
-func main() {
- protogen.Run(nil, func(gen *protogen.Plugin) error {
- for _, f := range gen.Files {
- if f.Generate {
- internal_gengogrpc.GenerateFile(gen, f)
- }
- }
- return nil
- })
-}
diff --git a/cmd/protoc-gen-go-grpc/testdata/gen_test.go b/cmd/protoc-gen-go-grpc/testdata/gen_test.go
deleted file mode 100644
index 71188b0..0000000
--- a/cmd/protoc-gen-go-grpc/testdata/gen_test.go
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright 2019 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Code generated by generate-protos. DO NOT EDIT.
-
-package main
-
-import (
- _ "google.golang.org/protobuf/cmd/protoc-gen-go-grpc/testdata/grpc"
-)
diff --git a/cmd/protoc-gen-go-grpc/testdata/go.mod b/cmd/protoc-gen-go-grpc/testdata/go.mod
deleted file mode 100644
index c987bb9..0000000
--- a/cmd/protoc-gen-go-grpc/testdata/go.mod
+++ /dev/null
@@ -1,11 +0,0 @@
-module google.golang.org/protobuf/cmd/protoc-gen-go-grpc/testdata
-
-go 1.9
-
-require (
- github.com/golang/protobuf v1.4.0-rc.1
- google.golang.org/grpc v1.27.0-pre.0.20200124224931-7afcfdd66b12
- google.golang.org/protobuf v1.0.0
-)
-
-replace google.golang.org/protobuf => ../../..
diff --git a/cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go b/cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go
deleted file mode 100644
index f5c9be6..0000000
--- a/cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.pb.go
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright 2018 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Code generated by protoc-gen-go. DO NOT EDIT.
-// source: cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.proto
-
-package grpc
-
-import (
- protoreflect "google.golang.org/protobuf/reflect/protoreflect"
- protoimpl "google.golang.org/protobuf/runtime/protoimpl"
- reflect "reflect"
-)
-
-var File_cmd_protoc_gen_go_grpc_testdata_grpc_deprecation_proto protoreflect.FileDescriptor
-
-var file_cmd_protoc_gen_go_grpc_testdata_grpc_deprecation_proto_rawDesc = []byte{
- 0x0a, 0x36, 0x63, 0x6d, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e,
- 0x2d, 0x67, 0x6f, 0x2d, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74,
- 0x61, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x64, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x69,
- 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x13, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74,
- 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x1a, 0x2f, 0x63,
- 0x6d, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f,
- 0x2d, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x67,
- 0x72, 0x70, 0x63, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x32, 0x6c,
- 0x0a, 0x11, 0x44, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65, 0x64, 0x53, 0x65, 0x72, 0x76,
- 0x69, 0x63, 0x65, 0x12, 0x52, 0x0a, 0x0e, 0x44, 0x65, 0x70, 0x72, 0x65, 0x63, 0x61, 0x74, 0x65,
- 0x64, 0x43, 0x61, 0x6c, 0x6c, 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
- 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x71, 0x75,
- 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72,
- 0x6f, 0x74, 0x6f, 0x63, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
- 0x73, 0x65, 0x22, 0x03, 0x88, 0x02, 0x01, 0x1a, 0x03, 0x88, 0x02, 0x01, 0x42, 0x3c, 0x5a, 0x3a,
- 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72,
- 0x67, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x63, 0x6d, 0x64, 0x2f, 0x70,
- 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x2f, 0x74, 0x65, 0x73,
- 0x74, 0x64, 0x61, 0x74, 0x61, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
- 0x6f, 0x33,
-}
-
-var file_cmd_protoc_gen_go_grpc_testdata_grpc_deprecation_proto_goTypes = []interface{}{
- (*Request)(nil), // 0: goproto.protoc.grpc.Request
- (*Response)(nil), // 1: goproto.protoc.grpc.Response
-}
-var file_cmd_protoc_gen_go_grpc_testdata_grpc_deprecation_proto_depIdxs = []int32{
- 0, // 0: goproto.protoc.grpc.DeprecatedService.DeprecatedCall:input_type -> goproto.protoc.grpc.Request
- 1, // 1: goproto.protoc.grpc.DeprecatedService.DeprecatedCall:output_type -> goproto.protoc.grpc.Response
- 1, // [1:2] is the sub-list for method output_type
- 0, // [0:1] is the sub-list for method input_type
- 0, // [0:0] is the sub-list for extension type_name
- 0, // [0:0] is the sub-list for extension extendee
- 0, // [0:0] is the sub-list for field type_name
-}
-
-func init() { file_cmd_protoc_gen_go_grpc_testdata_grpc_deprecation_proto_init() }
-func file_cmd_protoc_gen_go_grpc_testdata_grpc_deprecation_proto_init() {
- if File_cmd_protoc_gen_go_grpc_testdata_grpc_deprecation_proto != nil {
- return
- }
- file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_init()
- type x struct{}
- out := protoimpl.TypeBuilder{
- File: protoimpl.DescBuilder{
- GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
- RawDescriptor: file_cmd_protoc_gen_go_grpc_testdata_grpc_deprecation_proto_rawDesc,
- NumEnums: 0,
- NumMessages: 0,
- NumExtensions: 0,
- NumServices: 1,
- },
- GoTypes: file_cmd_protoc_gen_go_grpc_testdata_grpc_deprecation_proto_goTypes,
- DependencyIndexes: file_cmd_protoc_gen_go_grpc_testdata_grpc_deprecation_proto_depIdxs,
- }.Build()
- File_cmd_protoc_gen_go_grpc_testdata_grpc_deprecation_proto = out.File
- file_cmd_protoc_gen_go_grpc_testdata_grpc_deprecation_proto_rawDesc = nil
- file_cmd_protoc_gen_go_grpc_testdata_grpc_deprecation_proto_goTypes = nil
- file_cmd_protoc_gen_go_grpc_testdata_grpc_deprecation_proto_depIdxs = nil
-}
diff --git a/cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.proto b/cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.proto
deleted file mode 100644
index 7ce8571..0000000
--- a/cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.proto
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2018 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-syntax = "proto3";
-
-package goproto.protoc.grpc;
-
-import "cmd/protoc-gen-go-grpc/testdata/grpc/grpc.proto";
-
-option go_package = "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/grpc";
-
-service DeprecatedService {
- option deprecated = true;
-
- rpc DeprecatedCall(Request) returns (Response) {
- option deprecated = true;
- }
-}
diff --git a/cmd/protoc-gen-go-grpc/testdata/grpc/deprecation_grpc.pb.go b/cmd/protoc-gen-go-grpc/testdata/grpc/deprecation_grpc.pb.go
deleted file mode 100644
index f78902d..0000000
--- a/cmd/protoc-gen-go-grpc/testdata/grpc/deprecation_grpc.pb.go
+++ /dev/null
@@ -1,99 +0,0 @@
-// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
-
-package grpc
-
-import (
- context "context"
- grpc "google.golang.org/grpc"
- codes "google.golang.org/grpc/codes"
- status "google.golang.org/grpc/status"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConnInterface
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion6
-
-// DeprecatedServiceClient is the client API for DeprecatedService service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-//
-// Deprecated: Do not use.
-type DeprecatedServiceClient interface {
- // Deprecated: Do not use.
- DeprecatedCall(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
-}
-
-type deprecatedServiceClient struct {
- cc grpc.ClientConnInterface
-}
-
-// Deprecated: Do not use.
-func NewDeprecatedServiceClient(cc grpc.ClientConnInterface) DeprecatedServiceClient {
- return &deprecatedServiceClient{cc}
-}
-
-// Deprecated: Do not use.
-func (c *deprecatedServiceClient) DeprecatedCall(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) {
- out := new(Response)
- err := c.cc.Invoke(ctx, "/goproto.protoc.grpc.DeprecatedService/DeprecatedCall", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-// DeprecatedServiceServer is the server API for DeprecatedService service.
-//
-// Deprecated: Do not use.
-type DeprecatedServiceServer interface {
- // Deprecated: Do not use.
- DeprecatedCall(context.Context, *Request) (*Response, error)
-}
-
-// UnimplementedDeprecatedServiceServer can be embedded to have forward compatible implementations.
-type UnimplementedDeprecatedServiceServer struct {
-}
-
-func (*UnimplementedDeprecatedServiceServer) DeprecatedCall(context.Context, *Request) (*Response, error) {
- return nil, status.Errorf(codes.Unimplemented, "method DeprecatedCall not implemented")
-}
-
-// Deprecated: Do not use.
-func RegisterDeprecatedServiceServer(s *grpc.Server, srv DeprecatedServiceServer) {
- s.RegisterService(&_DeprecatedService_serviceDesc, srv)
-}
-
-func _DeprecatedService_DeprecatedCall_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(Request)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(DeprecatedServiceServer).DeprecatedCall(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/goproto.protoc.grpc.DeprecatedService/DeprecatedCall",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(DeprecatedServiceServer).DeprecatedCall(ctx, req.(*Request))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-var _DeprecatedService_serviceDesc = grpc.ServiceDesc{
- ServiceName: "goproto.protoc.grpc.DeprecatedService",
- HandlerType: (*DeprecatedServiceServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "DeprecatedCall",
- Handler: _DeprecatedService_DeprecatedCall_Handler,
- },
- },
- Streams: []grpc.StreamDesc{},
- Metadata: "cmd/protoc-gen-go-grpc/testdata/grpc/deprecation.proto",
-}
diff --git a/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go b/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go
deleted file mode 100644
index 3173554..0000000
--- a/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.pb.go
+++ /dev/null
@@ -1,211 +0,0 @@
-// Copyright 2018 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// Code generated by protoc-gen-go. DO NOT EDIT.
-// source: cmd/protoc-gen-go-grpc/testdata/grpc/grpc.proto
-
-package grpc
-
-import (
- protoreflect "google.golang.org/protobuf/reflect/protoreflect"
- protoimpl "google.golang.org/protobuf/runtime/protoimpl"
- reflect "reflect"
- sync "sync"
-)
-
-type Request struct {
- state protoimpl.MessageState
- sizeCache protoimpl.SizeCache
- unknownFields protoimpl.UnknownFields
-}
-
-func (x *Request) Reset() {
- *x = Request{}
- if protoimpl.UnsafeEnabled {
- mi := &file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_msgTypes[0]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
- }
-}
-
-func (x *Request) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*Request) ProtoMessage() {}
-
-func (x *Request) ProtoReflect() protoreflect.Message {
- mi := &file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_msgTypes[0]
- if protoimpl.UnsafeEnabled && x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use Request.ProtoReflect.Descriptor instead.
-func (*Request) Descriptor() ([]byte, []int) {
- return file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_rawDescGZIP(), []int{0}
-}
-
-type Response struct {
- state protoimpl.MessageState
- sizeCache protoimpl.SizeCache
- unknownFields protoimpl.UnknownFields
-}
-
-func (x *Response) Reset() {
- *x = Response{}
- if protoimpl.UnsafeEnabled {
- mi := &file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_msgTypes[1]
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- ms.StoreMessageInfo(mi)
- }
-}
-
-func (x *Response) String() string {
- return protoimpl.X.MessageStringOf(x)
-}
-
-func (*Response) ProtoMessage() {}
-
-func (x *Response) ProtoReflect() protoreflect.Message {
- mi := &file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_msgTypes[1]
- if protoimpl.UnsafeEnabled && x != nil {
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
- if ms.LoadMessageInfo() == nil {
- ms.StoreMessageInfo(mi)
- }
- return ms
- }
- return mi.MessageOf(x)
-}
-
-// Deprecated: Use Response.ProtoReflect.Descriptor instead.
-func (*Response) Descriptor() ([]byte, []int) {
- return file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_rawDescGZIP(), []int{1}
-}
-
-var File_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto protoreflect.FileDescriptor
-
-var file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_rawDesc = []byte{
- 0x0a, 0x2f, 0x63, 0x6d, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e,
- 0x2d, 0x67, 0x6f, 0x2d, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61, 0x74,
- 0x61, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74,
- 0x6f, 0x12, 0x13, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
- 0x63, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x22, 0x09, 0x0a, 0x07, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
- 0x74, 0x22, 0x0a, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x32, 0xc9, 0x02,
- 0x0a, 0x0c, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x49,
- 0x0a, 0x0a, 0x75, 0x6e, 0x61, 0x72, 0x79, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x12, 0x1c, 0x2e, 0x67,
- 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2e, 0x67, 0x72,
- 0x70, 0x63, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x67, 0x6f, 0x70,
- 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2e, 0x67, 0x72, 0x70, 0x63,
- 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x50, 0x0a, 0x0f, 0x64, 0x6f, 0x77,
- 0x6e, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x12, 0x1c, 0x2e, 0x67,
- 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2e, 0x67, 0x72,
- 0x70, 0x63, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x67, 0x6f, 0x70,
- 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2e, 0x67, 0x72, 0x70, 0x63,
- 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x30, 0x01, 0x12, 0x4e, 0x0a, 0x0d, 0x75,
- 0x70, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x12, 0x1c, 0x2e, 0x67,
- 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2e, 0x67, 0x72,
- 0x70, 0x63, 0x2e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x67, 0x6f, 0x70,
- 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2e, 0x67, 0x72, 0x70, 0x63,
- 0x2e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, 0x12, 0x4c, 0x0a, 0x09, 0x62,
- 0x69, 0x64, 0x69, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x12, 0x1c, 0x2e, 0x67, 0x6f, 0x70, 0x72, 0x6f,
- 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x52,
- 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1d, 0x2e, 0x67, 0x6f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
- 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x63, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x73,
- 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x28, 0x01, 0x30, 0x01, 0x42, 0x3c, 0x5a, 0x3a, 0x67, 0x6f, 0x6f,
- 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x70,
- 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x63, 0x6d, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74,
- 0x6f, 0x63, 0x2d, 0x67, 0x65, 0x6e, 0x2d, 0x67, 0x6f, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x64, 0x61,
- 0x74, 0x61, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
-}
-
-var (
- file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_rawDescOnce sync.Once
- file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_rawDescData = file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_rawDesc
-)
-
-func file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_rawDescGZIP() []byte {
- file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_rawDescOnce.Do(func() {
- file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_rawDescData = protoimpl.X.CompressGZIP(file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_rawDescData)
- })
- return file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_rawDescData
-}
-
-var file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
-var file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_goTypes = []interface{}{
- (*Request)(nil), // 0: goproto.protoc.grpc.Request
- (*Response)(nil), // 1: goproto.protoc.grpc.Response
-}
-var file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_depIdxs = []int32{
- 0, // 0: goproto.protoc.grpc.test_service.unary_call:input_type -> goproto.protoc.grpc.Request
- 0, // 1: goproto.protoc.grpc.test_service.downstream_call:input_type -> goproto.protoc.grpc.Request
- 0, // 2: goproto.protoc.grpc.test_service.upstream_call:input_type -> goproto.protoc.grpc.Request
- 0, // 3: goproto.protoc.grpc.test_service.bidi_call:input_type -> goproto.protoc.grpc.Request
- 1, // 4: goproto.protoc.grpc.test_service.unary_call:output_type -> goproto.protoc.grpc.Response
- 1, // 5: goproto.protoc.grpc.test_service.downstream_call:output_type -> goproto.protoc.grpc.Response
- 1, // 6: goproto.protoc.grpc.test_service.upstream_call:output_type -> goproto.protoc.grpc.Response
- 1, // 7: goproto.protoc.grpc.test_service.bidi_call:output_type -> goproto.protoc.grpc.Response
- 4, // [4:8] is the sub-list for method output_type
- 0, // [0:4] is the sub-list for method input_type
- 0, // [0:0] is the sub-list for extension type_name
- 0, // [0:0] is the sub-list for extension extendee
- 0, // [0:0] is the sub-list for field type_name
-}
-
-func init() { file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_init() }
-func file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_init() {
- if File_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto != nil {
- return
- }
- if !protoimpl.UnsafeEnabled {
- file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*Request); i {
- case 0:
- return &v.state
- case 1:
- return &v.sizeCache
- case 2:
- return &v.unknownFields
- default:
- return nil
- }
- }
- file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
- switch v := v.(*Response); i {
- case 0:
- return &v.state
- case 1:
- return &v.sizeCache
- case 2:
- return &v.unknownFields
- default:
- return nil
- }
- }
- }
- type x struct{}
- out := protoimpl.TypeBuilder{
- File: protoimpl.DescBuilder{
- GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
- RawDescriptor: file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_rawDesc,
- NumEnums: 0,
- NumMessages: 2,
- NumExtensions: 0,
- NumServices: 1,
- },
- GoTypes: file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_goTypes,
- DependencyIndexes: file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_depIdxs,
- MessageInfos: file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_msgTypes,
- }.Build()
- File_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto = out.File
- file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_rawDesc = nil
- file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_goTypes = nil
- file_cmd_protoc_gen_go_grpc_testdata_grpc_grpc_proto_depIdxs = nil
-}
diff --git a/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.proto b/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.proto
deleted file mode 100644
index 1ea2862..0000000
--- a/cmd/protoc-gen-go-grpc/testdata/grpc/grpc.proto
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2018 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-syntax = "proto3";
-
-package goproto.protoc.grpc;
-
-option go_package = "google.golang.org/protobuf/cmd/protoc-gen-go/testdata/grpc";
-
-message Request {}
-message Response {}
-
-// Service and method names chosen to exercise the distinction between the
-// proto definition names and the CamelCased Go names.
-service test_service {
- rpc unary_call(Request) returns (Response);
-
- // This RPC streams from the server only.
- rpc downstream_call(Request) returns (stream Response);
-
- // This RPC streams from the client.
- rpc upstream_call(stream Request) returns (Response);
-
- // This one streams in both directions.
- rpc bidi_call(stream Request) returns (stream Response);
-}
diff --git a/cmd/protoc-gen-go-grpc/testdata/grpc/grpc_grpc.pb.go b/cmd/protoc-gen-go-grpc/testdata/grpc/grpc_grpc.pb.go
deleted file mode 100644
index 3017d53..0000000
--- a/cmd/protoc-gen-go-grpc/testdata/grpc/grpc_grpc.pb.go
+++ /dev/null
@@ -1,298 +0,0 @@
-// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
-
-package grpc
-
-import (
- context "context"
- grpc "google.golang.org/grpc"
- codes "google.golang.org/grpc/codes"
- status "google.golang.org/grpc/status"
-)
-
-// Reference imports to suppress errors if they are not otherwise used.
-var _ context.Context
-var _ grpc.ClientConnInterface
-
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the grpc package it is being compiled against.
-const _ = grpc.SupportPackageIsVersion6
-
-// TestServiceClient is the client API for TestService service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type TestServiceClient interface {
- UnaryCall(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error)
- // This RPC streams from the server only.
- DownstreamCall(ctx context.Context, in *Request, opts ...grpc.CallOption) (TestService_DownstreamCallClient, error)
- // This RPC streams from the client.
- UpstreamCall(ctx context.Context, opts ...grpc.CallOption) (TestService_UpstreamCallClient, error)
- // This one streams in both directions.
- BidiCall(ctx context.Context, opts ...grpc.CallOption) (TestService_BidiCallClient, error)
-}
-
-type testServiceClient struct {
- cc grpc.ClientConnInterface
-}
-
-func NewTestServiceClient(cc grpc.ClientConnInterface) TestServiceClient {
- return &testServiceClient{cc}
-}
-
-func (c *testServiceClient) UnaryCall(ctx context.Context, in *Request, opts ...grpc.CallOption) (*Response, error) {
- out := new(Response)
- err := c.cc.Invoke(ctx, "/goproto.protoc.grpc.test_service/unary_call", in, out, opts...)
- if err != nil {
- return nil, err
- }
- return out, nil
-}
-
-func (c *testServiceClient) DownstreamCall(ctx context.Context, in *Request, opts ...grpc.CallOption) (TestService_DownstreamCallClient, error) {
- stream, err := c.cc.NewStream(ctx, &_TestService_serviceDesc.Streams[0], "/goproto.protoc.grpc.test_service/downstream_call", opts...)
- if err != nil {
- return nil, err
- }
- x := &testServiceDownstreamCallClient{stream}
- if err := x.ClientStream.SendMsg(in); err != nil {
- return nil, err
- }
- if err := x.ClientStream.CloseSend(); err != nil {
- return nil, err
- }
- return x, nil
-}
-
-type TestService_DownstreamCallClient interface {
- Recv() (*Response, error)
- grpc.ClientStream
-}
-
-type testServiceDownstreamCallClient struct {
- grpc.ClientStream
-}
-
-func (x *testServiceDownstreamCallClient) Recv() (*Response, error) {
- m := new(Response)
- if err := x.ClientStream.RecvMsg(m); err != nil {
- return nil, err
- }
- return m, nil
-}
-
-func (c *testServiceClient) UpstreamCall(ctx context.Context, opts ...grpc.CallOption) (TestService_UpstreamCallClient, error) {
- stream, err := c.cc.NewStream(ctx, &_TestService_serviceDesc.Streams[1], "/goproto.protoc.grpc.test_service/upstream_call", opts...)
- if err != nil {
- return nil, err
- }
- x := &testServiceUpstreamCallClient{stream}
- return x, nil
-}
-
-type TestService_UpstreamCallClient interface {
- Send(*Request) error
- CloseAndRecv() (*Response, error)
- grpc.ClientStream
-}
-
-type testServiceUpstreamCallClient struct {
- grpc.ClientStream
-}
-
-func (x *testServiceUpstreamCallClient) Send(m *Request) error {
- return x.ClientStream.SendMsg(m)
-}
-
-func (x *testServiceUpstreamCallClient) CloseAndRecv() (*Response, error) {
- if err := x.ClientStream.CloseSend(); err != nil {
- return nil, err
- }
- m := new(Response)
- if err := x.ClientStream.RecvMsg(m); err != nil {
- return nil, err
- }
- return m, nil
-}
-
-func (c *testServiceClient) BidiCall(ctx context.Context, opts ...grpc.CallOption) (TestService_BidiCallClient, error) {
- stream, err := c.cc.NewStream(ctx, &_TestService_serviceDesc.Streams[2], "/goproto.protoc.grpc.test_service/bidi_call", opts...)
- if err != nil {
- return nil, err
- }
- x := &testServiceBidiCallClient{stream}
- return x, nil
-}
-
-type TestService_BidiCallClient interface {
- Send(*Request) error
- Recv() (*Response, error)
- grpc.ClientStream
-}
-
-type testServiceBidiCallClient struct {
- grpc.ClientStream
-}
-
-func (x *testServiceBidiCallClient) Send(m *Request) error {
- return x.ClientStream.SendMsg(m)
-}
-
-func (x *testServiceBidiCallClient) Recv() (*Response, error) {
- m := new(Response)
- if err := x.ClientStream.RecvMsg(m); err != nil {
- return nil, err
- }
- return m, nil
-}
-
-// TestServiceServer is the server API for TestService service.
-type TestServiceServer interface {
- UnaryCall(context.Context, *Request) (*Response, error)
- // This RPC streams from the server only.
- DownstreamCall(*Request, TestService_DownstreamCallServer) error
- // This RPC streams from the client.
- UpstreamCall(TestService_UpstreamCallServer) error
- // This one streams in both directions.
- BidiCall(TestService_BidiCallServer) error
-}
-
-// UnimplementedTestServiceServer can be embedded to have forward compatible implementations.
-type UnimplementedTestServiceServer struct {
-}
-
-func (*UnimplementedTestServiceServer) UnaryCall(context.Context, *Request) (*Response, error) {
- return nil, status.Errorf(codes.Unimplemented, "method UnaryCall not implemented")
-}
-func (*UnimplementedTestServiceServer) DownstreamCall(*Request, TestService_DownstreamCallServer) error {
- return status.Errorf(codes.Unimplemented, "method DownstreamCall not implemented")
-}
-func (*UnimplementedTestServiceServer) UpstreamCall(TestService_UpstreamCallServer) error {
- return status.Errorf(codes.Unimplemented, "method UpstreamCall not implemented")
-}
-func (*UnimplementedTestServiceServer) BidiCall(TestService_BidiCallServer) error {
- return status.Errorf(codes.Unimplemented, "method BidiCall not implemented")
-}
-
-func RegisterTestServiceServer(s *grpc.Server, srv TestServiceServer) {
- s.RegisterService(&_TestService_serviceDesc, srv)
-}
-
-func _TestService_UnaryCall_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(Request)
- if err := dec(in); err != nil {
- return nil, err
- }
- if interceptor == nil {
- return srv.(TestServiceServer).UnaryCall(ctx, in)
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/goproto.protoc.grpc.test_service/UnaryCall",
- }
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- return srv.(TestServiceServer).UnaryCall(ctx, req.(*Request))
- }
- return interceptor(ctx, in, info, handler)
-}
-
-func _TestService_DownstreamCall_Handler(srv interface{}, stream grpc.ServerStream) error {
- m := new(Request)
- if err := stream.RecvMsg(m); err != nil {
- return err
- }
- return srv.(TestServiceServer).DownstreamCall(m, &testServiceDownstreamCallServer{stream})
-}
-
-type TestService_DownstreamCallServer interface {
- Send(*Response) error
- grpc.ServerStream
-}
-
-type testServiceDownstreamCallServer struct {
- grpc.ServerStream
-}
-
-func (x *testServiceDownstreamCallServer) Send(m *Response) error {
- return x.ServerStream.SendMsg(m)
-}
-
-func _TestService_UpstreamCall_Handler(srv interface{}, stream grpc.ServerStream) error {
- return srv.(TestServiceServer).UpstreamCall(&testServiceUpstreamCallServer{stream})
-}
-
-type TestService_UpstreamCallServer interface {
- SendAndClose(*Response) error
- Recv() (*Request, error)
- grpc.ServerStream
-}
-
-type testServiceUpstreamCallServer struct {
- grpc.ServerStream
-}
-
-func (x *testServiceUpstreamCallServer) SendAndClose(m *Response) error {
- return x.ServerStream.SendMsg(m)
-}
-
-func (x *testServiceUpstreamCallServer) Recv() (*Request, error) {
- m := new(Request)
- if err := x.ServerStream.RecvMsg(m); err != nil {
- return nil, err
- }
- return m, nil
-}
-
-func _TestService_BidiCall_Handler(srv interface{}, stream grpc.ServerStream) error {
- return srv.(TestServiceServer).BidiCall(&testServiceBidiCallServer{stream})
-}
-
-type TestService_BidiCallServer interface {
- Send(*Response) error
- Recv() (*Request, error)
- grpc.ServerStream
-}
-
-type testServiceBidiCallServer struct {
- grpc.ServerStream
-}
-
-func (x *testServiceBidiCallServer) Send(m *Response) error {
- return x.ServerStream.SendMsg(m)
-}
-
-func (x *testServiceBidiCallServer) Recv() (*Request, error) {
- m := new(Request)
- if err := x.ServerStream.RecvMsg(m); err != nil {
- return nil, err
- }
- return m, nil
-}
-
-var _TestService_serviceDesc = grpc.ServiceDesc{
- ServiceName: "goproto.protoc.grpc.test_service",
- HandlerType: (*TestServiceServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "unary_call",
- Handler: _TestService_UnaryCall_Handler,
- },
- },
- Streams: []grpc.StreamDesc{
- {
- StreamName: "downstream_call",
- Handler: _TestService_DownstreamCall_Handler,
- ServerStreams: true,
- },
- {
- StreamName: "upstream_call",
- Handler: _TestService_UpstreamCall_Handler,
- ClientStreams: true,
- },
- {
- StreamName: "bidi_call",
- Handler: _TestService_BidiCall_Handler,
- ServerStreams: true,
- ClientStreams: true,
- },
- },
- Metadata: "cmd/protoc-gen-go-grpc/testdata/grpc/grpc.proto",
-}
diff --git a/integration_test.go b/integration_test.go
index 2e619ce..1afd13b 100644
--- a/integration_test.go
+++ b/integration_test.go
@@ -73,7 +73,6 @@
if goVersion == golangLatest {
runGo("ProtoLegacy", workDir, "go", "test", "-race", "-tags", "protolegacy", "./...")
runGo("ProtocGenGo", "cmd/protoc-gen-go/testdata", "go", "test")
- runGo("ProtocGenGoGRPC", "cmd/protoc-gen-go-grpc/testdata", "go", "test")
runGo("Conformance", "internal/conformance", "go", "test", "-execute")
}
}
diff --git a/internal/cmd/generate-protos/main.go b/internal/cmd/generate-protos/main.go
index 652f236..00dc876 100644
--- a/internal/cmd/generate-protos/main.go
+++ b/internal/cmd/generate-protos/main.go
@@ -19,7 +19,6 @@
"sort"
"strings"
- gengogrpc "google.golang.org/protobuf/cmd/protoc-gen-go-grpc/internal_gengogrpc"
gengo "google.golang.org/protobuf/cmd/protoc-gen-go/internal_gengo"
"google.golang.org/protobuf/compiler/protogen"
"google.golang.org/protobuf/internal/detrand"
@@ -66,24 +65,17 @@
// When the environment variable RUN_AS_PROTOC_PLUGIN is set,
// we skip running main and instead act as a protoc plugin.
// This allows the binary to pass itself to protoc.
- if plugins := os.Getenv("RUN_AS_PROTOC_PLUGIN"); plugins != "" {
+ if plugin := os.Getenv("RUN_AS_PROTOC_PLUGIN"); plugin != "" {
// Disable deliberate output instability for generated files.
// This is reasonable since we fully control the output.
detrand.Disable()
protogen.Run(nil, func(gen *protogen.Plugin) error {
- for _, plugin := range strings.Split(plugins, ",") {
- for _, file := range gen.Files {
- if file.Generate {
- switch plugin {
- case "go":
- gengo.GenerateVersionMarkers = false
- gengo.GenerateFile(gen, file)
- generateFieldNumbers(gen, file)
- case "gogrpc":
- gengogrpc.GenerateFile(gen, file)
- }
- }
+ for _, file := range gen.Files {
+ if file.Generate {
+ gengo.GenerateVersionMarkers = false
+ gengo.GenerateFile(gen, file)
+ generateFieldNumbers(gen, file)
}
}
return nil
@@ -128,14 +120,12 @@
// Generate all local proto files (except version-locked files).
dirs := []struct {
path string
- grpcPlugin bool
annotateFor map[string]bool
exclude map[string]bool
}{
{path: "cmd/protoc-gen-go/testdata", annotateFor: map[string]bool{
"cmd/protoc-gen-go/testdata/annotations/annotations.proto": true},
},
- {path: "cmd/protoc-gen-go-grpc/testdata", grpcPlugin: true},
{path: "internal/testprotos", exclude: map[string]bool{
"internal/testprotos/irregular/irregular.proto": true,
}},
@@ -170,13 +160,7 @@
opts += ",annotate_code"
}
- // Determine which set of plugins to use.
- plugins := "go"
- if d.grpcPlugin {
- plugins += ",gogrpc"
- }
-
- protoc(plugins, "-I"+filepath.Join(protoRoot, "src"), "-I"+repoRoot, "--go_out="+opts+":"+dstDir, relPath)
+ protoc("-I"+filepath.Join(protoRoot, "src"), "-I"+repoRoot, "--go_out="+opts+":"+dstDir, relPath)
return nil
})
@@ -248,11 +232,10 @@
{"src", "google/protobuf/wrappers.proto"},
}
for _, f := range files {
- protoc("go", "-I"+filepath.Join(protoRoot, f.prefix), "--go_out="+protoMapOpt()+":"+tmpDir, f.path)
+ protoc("-I"+filepath.Join(protoRoot, f.prefix), "--go_out="+protoMapOpt()+":"+tmpDir, f.path)
}
// Special-case: Generate field_mask.proto into a local test-only capy.
- //protoc("go", "-I"+filepath.Join(protoRoot, "src/google/protobuf"), "--go_out=paths=source_relative:"+filepath.Join(tmpDir, modulePath, "internal/testprotos/fieldmaskpb"), "field_mask.proto")
copyFile(
filepath.Join(tmpDir, "google.golang.org/protobuf/internal/testprotos/fieldmaskpb/field_mask.pb.go"),
filepath.Join(tmpDir, "google.golang.org/genproto/protobuf/field_mask/field_mask.pb.go"),
@@ -261,10 +244,10 @@
syncOutput(repoRoot, filepath.Join(tmpDir, modulePath))
}
-func protoc(plugins string, args ...string) {
+func protoc(args ...string) {
cmd := exec.Command("protoc", "--plugin=protoc-gen-go="+os.Args[0])
cmd.Args = append(cmd.Args, args...)
- cmd.Env = append(os.Environ(), "RUN_AS_PROTOC_PLUGIN="+plugins)
+ cmd.Env = append(os.Environ(), "RUN_AS_PROTOC_PLUGIN=1")
out, err := cmd.CombinedOutput()
if err != nil {
fmt.Printf("executing: %v\n%s\n", strings.Join(cmd.Args, " "), out)