diff --git a/go.mod b/go.mod index 628c2b4..10a5bf1 100644 --- a/go.mod +++ b/go.mod @@ -20,7 +20,6 @@ github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8 // indirect github.com/go-logfmt/logfmt v0.5.0 github.com/go-stack/stack v1.8.0 - github.com/golang/protobuf v1.5.2 github.com/google/btree v1.0.0 // indirect github.com/hashicorp/consul/api v1.3.0 github.com/hashicorp/golang-lru v0.5.1 // indirect @@ -49,6 +48,7 @@ golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 golang.org/x/tools v0.1.2 google.golang.org/grpc v1.38.0 + google.golang.org/protobuf v1.26.0 gopkg.in/gcfg.v1 v1.2.3 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect ) diff --git a/transport/grpc/_grpc_test/pb/generate.go b/transport/grpc/_grpc_test/pb/generate.go index aa20bb6..0ed7406 100644 --- a/transport/grpc/_grpc_test/pb/generate.go +++ b/transport/grpc/_grpc_test/pb/generate.go @@ -1,3 +1,3 @@ package pb -//go:generate protoc test.proto --go_out=plugins=grpc:. +//go:generate protoc test.proto --go_out=. --go-grpc_out=. --go_opt=Mtest.proto=github.com/go-kit/kit/transport/grpc/_grpc_test/pb --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative --go-grpc_opt=Mtest.proto=github.com/go-kit/kit/transport/grpc/_grpc_test/pb diff --git a/transport/grpc/_grpc_test/pb/test.pb.go b/transport/grpc/_grpc_test/pb/test.pb.go index 8976747..66e94b3 100644 --- a/transport/grpc/_grpc_test/pb/test.pb.go +++ b/transport/grpc/_grpc_test/pb/test.pb.go @@ -1,201 +1,216 @@ // Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v3.16.0 // source: test.proto package pb import ( - context "context" - fmt "fmt" - proto "github.com/golang/protobuf/proto" - grpc "google.golang.org/grpc" - math "math" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) type TestRequest struct { - A string `protobuf:"bytes,1,opt,name=a,proto3" json:"a,omitempty"` - B int64 `protobuf:"varint,2,opt,name=b,proto3" json:"b,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *TestRequest) Reset() { *m = TestRequest{} } -func (m *TestRequest) String() string { return proto.CompactTextString(m) } -func (*TestRequest) ProtoMessage() {} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + A string `protobuf:"bytes,1,opt,name=a,proto3" json:"a,omitempty"` + B int64 `protobuf:"varint,2,opt,name=b,proto3" json:"b,omitempty"` +} + +func (x *TestRequest) Reset() { + *x = TestRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_test_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TestRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TestRequest) ProtoMessage() {} + +func (x *TestRequest) ProtoReflect() protoreflect.Message { + mi := &file_test_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 TestRequest.ProtoReflect.Descriptor instead. func (*TestRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_c161fcfdc0c3ff1e, []int{0} -} - -func (m *TestRequest) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_TestRequest.Unmarshal(m, b) -} -func (m *TestRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_TestRequest.Marshal(b, m, deterministic) -} -func (m *TestRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_TestRequest.Merge(m, src) -} -func (m *TestRequest) XXX_Size() int { - return xxx_messageInfo_TestRequest.Size(m) -} -func (m *TestRequest) XXX_DiscardUnknown() { - xxx_messageInfo_TestRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_TestRequest proto.InternalMessageInfo - -func (m *TestRequest) GetA() string { - if m != nil { - return m.A + return file_test_proto_rawDescGZIP(), []int{0} +} + +func (x *TestRequest) GetA() string { + if x != nil { + return x.A } return "" } -func (m *TestRequest) GetB() int64 { - if m != nil { - return m.B +func (x *TestRequest) GetB() int64 { + if x != nil { + return x.B } return 0 } type TestResponse struct { - V string `protobuf:"bytes,1,opt,name=v,proto3" json:"v,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` -} - -func (m *TestResponse) Reset() { *m = TestResponse{} } -func (m *TestResponse) String() string { return proto.CompactTextString(m) } -func (*TestResponse) ProtoMessage() {} + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + V string `protobuf:"bytes,1,opt,name=v,proto3" json:"v,omitempty"` +} + +func (x *TestResponse) Reset() { + *x = TestResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_test_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TestResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TestResponse) ProtoMessage() {} + +func (x *TestResponse) ProtoReflect() protoreflect.Message { + mi := &file_test_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 TestResponse.ProtoReflect.Descriptor instead. func (*TestResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_c161fcfdc0c3ff1e, []int{1} -} - -func (m *TestResponse) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_TestResponse.Unmarshal(m, b) -} -func (m *TestResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_TestResponse.Marshal(b, m, deterministic) -} -func (m *TestResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_TestResponse.Merge(m, src) -} -func (m *TestResponse) XXX_Size() int { - return xxx_messageInfo_TestResponse.Size(m) -} -func (m *TestResponse) XXX_DiscardUnknown() { - xxx_messageInfo_TestResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_TestResponse proto.InternalMessageInfo - -func (m *TestResponse) GetV() string { - if m != nil { - return m.V + return file_test_proto_rawDescGZIP(), []int{1} +} + +func (x *TestResponse) GetV() string { + if x != nil { + return x.V } return "" } -func init() { - proto.RegisterType((*TestRequest)(nil), "pb.TestRequest") - proto.RegisterType((*TestResponse)(nil), "pb.TestResponse") -} - -func init() { proto.RegisterFile("test.proto", fileDescriptor_c161fcfdc0c3ff1e) } - -var fileDescriptor_c161fcfdc0c3ff1e = []byte{ - // 129 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2a, 0x49, 0x2d, 0x2e, - 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x62, 0x2a, 0x48, 0x52, 0xd2, 0xe4, 0xe2, 0x0e, 0x49, - 0x2d, 0x2e, 0x09, 0x4a, 0x2d, 0x2c, 0x4d, 0x2d, 0x2e, 0x11, 0xe2, 0xe1, 0x62, 0x4c, 0x94, 0x60, - 0x54, 0x60, 0xd4, 0xe0, 0x0c, 0x62, 0x4c, 0x04, 0xf1, 0x92, 0x24, 0x98, 0x14, 0x18, 0x35, 0x98, - 0x83, 0x18, 0x93, 0x94, 0x64, 0xb8, 0x78, 0x20, 0x4a, 0x8b, 0x0b, 0xf2, 0xf3, 0x8a, 0x53, 0x41, - 0xb2, 0x65, 0x30, 0xb5, 0x65, 0x46, 0xc6, 0x5c, 0x2c, 0x20, 0x59, 0x21, 0x6d, 0x28, 0xcd, 0xaf, - 0x57, 0x90, 0xa4, 0x87, 0x64, 0xb4, 0x94, 0x00, 0x42, 0x00, 0x62, 0x80, 0x12, 0x43, 0x12, 0x1b, - 0xd8, 0x21, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x49, 0xfc, 0xd8, 0xf1, 0x96, 0x00, 0x00, - 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// 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.SupportPackageIsVersion4 - -// TestClient is the client API for Test service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type TestClient interface { - Test(ctx context.Context, in *TestRequest, opts ...grpc.CallOption) (*TestResponse, error) -} - -type testClient struct { - cc *grpc.ClientConn -} - -func NewTestClient(cc *grpc.ClientConn) TestClient { - return &testClient{cc} -} - -func (c *testClient) Test(ctx context.Context, in *TestRequest, opts ...grpc.CallOption) (*TestResponse, error) { - out := new(TestResponse) - err := c.cc.Invoke(ctx, "/pb.Test/Test", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// TestServer is the server API for Test service. -type TestServer interface { - Test(context.Context, *TestRequest) (*TestResponse, error) -} - -func RegisterTestServer(s *grpc.Server, srv TestServer) { - s.RegisterService(&_Test_serviceDesc, srv) -} - -func _Test_Test_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(TestRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(TestServer).Test(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/pb.Test/Test", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(TestServer).Test(ctx, req.(*TestRequest)) - } - return interceptor(ctx, in, info, handler) -} - -var _Test_serviceDesc = grpc.ServiceDesc{ - ServiceName: "pb.Test", - HandlerType: (*TestServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Test", - Handler: _Test_Test_Handler, +var File_test_proto protoreflect.FileDescriptor + +var file_test_proto_rawDesc = []byte{ + 0x0a, 0x0a, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, + 0x22, 0x29, 0x0a, 0x0b, 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x0c, 0x0a, 0x01, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x01, 0x61, 0x12, 0x0c, 0x0a, + 0x01, 0x62, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x01, 0x62, 0x22, 0x1c, 0x0a, 0x0c, 0x54, + 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x0c, 0x0a, 0x01, 0x76, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x01, 0x76, 0x32, 0x33, 0x0a, 0x04, 0x54, 0x65, 0x73, + 0x74, 0x12, 0x2b, 0x0a, 0x04, 0x54, 0x65, 0x73, 0x74, 0x12, 0x0f, 0x2e, 0x70, 0x62, 0x2e, 0x54, + 0x65, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x70, 0x62, 0x2e, + 0x54, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_test_proto_rawDescOnce sync.Once + file_test_proto_rawDescData = file_test_proto_rawDesc +) + +func file_test_proto_rawDescGZIP() []byte { + file_test_proto_rawDescOnce.Do(func() { + file_test_proto_rawDescData = protoimpl.X.CompressGZIP(file_test_proto_rawDescData) + }) + return file_test_proto_rawDescData +} + +var file_test_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_test_proto_goTypes = []interface{}{ + (*TestRequest)(nil), // 0: pb.TestRequest + (*TestResponse)(nil), // 1: pb.TestResponse +} +var file_test_proto_depIdxs = []int32{ + 0, // 0: pb.Test.Test:input_type -> pb.TestRequest + 1, // 1: pb.Test.Test:output_type -> pb.TestResponse + 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_test_proto_init() } +func file_test_proto_init() { + if File_test_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_test_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TestRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_test_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TestResponse); 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_test_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "test.proto", -} + GoTypes: file_test_proto_goTypes, + DependencyIndexes: file_test_proto_depIdxs, + MessageInfos: file_test_proto_msgTypes, + }.Build() + File_test_proto = out.File + file_test_proto_rawDesc = nil + file_test_proto_goTypes = nil + file_test_proto_depIdxs = nil +} diff --git a/transport/grpc/_grpc_test/pb/test_grpc.pb.go b/transport/grpc/_grpc_test/pb/test_grpc.pb.go new file mode 100644 index 0000000..d442317 --- /dev/null +++ b/transport/grpc/_grpc_test/pb/test_grpc.pb.go @@ -0,0 +1,101 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. + +package pb + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// TestClient is the client API for Test service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type TestClient interface { + Test(ctx context.Context, in *TestRequest, opts ...grpc.CallOption) (*TestResponse, error) +} + +type testClient struct { + cc grpc.ClientConnInterface +} + +func NewTestClient(cc grpc.ClientConnInterface) TestClient { + return &testClient{cc} +} + +func (c *testClient) Test(ctx context.Context, in *TestRequest, opts ...grpc.CallOption) (*TestResponse, error) { + out := new(TestResponse) + err := c.cc.Invoke(ctx, "/pb.Test/Test", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// TestServer is the server API for Test service. +// All implementations must embed UnimplementedTestServer +// for forward compatibility +type TestServer interface { + Test(context.Context, *TestRequest) (*TestResponse, error) + mustEmbedUnimplementedTestServer() +} + +// UnimplementedTestServer must be embedded to have forward compatible implementations. +type UnimplementedTestServer struct { +} + +func (UnimplementedTestServer) Test(context.Context, *TestRequest) (*TestResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Test not implemented") +} +func (UnimplementedTestServer) mustEmbedUnimplementedTestServer() {} + +// UnsafeTestServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to TestServer will +// result in compilation errors. +type UnsafeTestServer interface { + mustEmbedUnimplementedTestServer() +} + +func RegisterTestServer(s grpc.ServiceRegistrar, srv TestServer) { + s.RegisterService(&Test_ServiceDesc, srv) +} + +func _Test_Test_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(TestRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(TestServer).Test(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/pb.Test/Test", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(TestServer).Test(ctx, req.(*TestRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Test_ServiceDesc is the grpc.ServiceDesc for Test service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Test_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "pb.Test", + HandlerType: (*TestServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Test", + Handler: _Test_Test_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "test.proto", +} diff --git a/transport/grpc/_grpc_test/server.go b/transport/grpc/_grpc_test/server.go index 26cbf34..98c1ad7 100644 --- a/transport/grpc/_grpc_test/server.go +++ b/transport/grpc/_grpc_test/server.go @@ -31,6 +31,8 @@ } type serverBinding struct { + pb.UnimplementedTestServer + test grpctransport.Handler } diff --git a/transport/http/proto/client.go b/transport/http/proto/client.go index cc729f9..25c6dbd 100644 --- a/transport/http/proto/client.go +++ b/transport/http/proto/client.go @@ -8,7 +8,7 @@ "net/http" httptransport "github.com/go-kit/kit/transport/http" - "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/proto" ) // EncodeProtoRequest is an EncodeRequestFunc that serializes the request as Protobuf. diff --git a/transport/http/proto/generate.go b/transport/http/proto/generate.go new file mode 100644 index 0000000..fe5893d --- /dev/null +++ b/transport/http/proto/generate.go @@ -0,0 +1,4 @@ +package proto + +//go:generate protoc proto_test.proto --go_out=. --go_opt=Mproto_test.proto=github.com/go-kit/kit/transport/http/proto --go_opt=paths=source_relative +//go:generate mv proto_test.pb.go proto_pb_test.go diff --git a/transport/http/proto/proto_pb_test.go b/transport/http/proto/proto_pb_test.go index 779d888..b8a1f7d 100644 --- a/transport/http/proto/proto_pb_test.go +++ b/transport/http/proto/proto_pb_test.go @@ -1,94 +1,158 @@ // Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.26.0 +// protoc v3.16.0 // source: proto_test.proto package proto import ( - fmt "fmt" - math "math" - - proto "github.com/golang/protobuf/proto" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) type Cat struct { - Age int32 `protobuf:"varint,1,opt,name=Age,proto3" json:"Age,omitempty"` - Breed string `protobuf:"bytes,2,opt,name=Breed,proto3" json:"Breed,omitempty"` - Name string `protobuf:"bytes,3,opt,name=Name,proto3" json:"Name,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Age int32 `protobuf:"varint,1,opt,name=Age,proto3" json:"Age,omitempty"` + Breed string `protobuf:"bytes,2,opt,name=Breed,proto3" json:"Breed,omitempty"` + Name string `protobuf:"bytes,3,opt,name=Name,proto3" json:"Name,omitempty"` } -func (m *Cat) Reset() { *m = Cat{} } -func (m *Cat) String() string { return proto.CompactTextString(m) } -func (*Cat) ProtoMessage() {} -func (*Cat) Descriptor() ([]byte, []int) { - return fileDescriptor_a794ba8d0e5440a3, []int{0} +func (x *Cat) Reset() { + *x = Cat{} + if protoimpl.UnsafeEnabled { + mi := &file_proto_test_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } } -func (m *Cat) XXX_Unmarshal(b []byte) error { - return xxx_messageInfo_Cat.Unmarshal(m, b) -} -func (m *Cat) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - return xxx_messageInfo_Cat.Marshal(b, m, deterministic) -} -func (m *Cat) XXX_Merge(src proto.Message) { - xxx_messageInfo_Cat.Merge(m, src) -} -func (m *Cat) XXX_Size() int { - return xxx_messageInfo_Cat.Size(m) -} -func (m *Cat) XXX_DiscardUnknown() { - xxx_messageInfo_Cat.DiscardUnknown(m) +func (x *Cat) String() string { + return protoimpl.X.MessageStringOf(x) } -var xxx_messageInfo_Cat proto.InternalMessageInfo +func (*Cat) ProtoMessage() {} -func (m *Cat) GetAge() int32 { - if m != nil { - return m.Age +func (x *Cat) ProtoReflect() protoreflect.Message { + mi := &file_proto_test_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 Cat.ProtoReflect.Descriptor instead. +func (*Cat) Descriptor() ([]byte, []int) { + return file_proto_test_proto_rawDescGZIP(), []int{0} +} + +func (x *Cat) GetAge() int32 { + if x != nil { + return x.Age } return 0 } -func (m *Cat) GetBreed() string { - if m != nil { - return m.Breed +func (x *Cat) GetBreed() string { + if x != nil { + return x.Breed } return "" } -func (m *Cat) GetName() string { - if m != nil { - return m.Name +func (x *Cat) GetName() string { + if x != nil { + return x.Name } return "" } -func init() { - proto.RegisterType((*Cat)(nil), "Cat") +var File_proto_test_proto protoreflect.FileDescriptor + +var file_proto_test_proto_rawDesc = []byte{ + 0x0a, 0x10, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x5f, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x22, 0x41, 0x0a, 0x03, 0x43, 0x61, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x41, 0x67, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x41, 0x67, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x42, + 0x72, 0x65, 0x65, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x42, 0x72, 0x65, 0x65, + 0x64, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } -func init() { proto.RegisterFile("proto_test.proto", fileDescriptor_a794ba8d0e5440a3) } +var ( + file_proto_test_proto_rawDescOnce sync.Once + file_proto_test_proto_rawDescData = file_proto_test_proto_rawDesc +) -var fileDescriptor_a794ba8d0e5440a3 = []byte{ - // 98 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x28, 0x28, 0xca, 0x2f, - 0xc9, 0x8f, 0x2f, 0x49, 0x2d, 0x2e, 0xd1, 0x03, 0x33, 0x95, 0x1c, 0xb9, 0x98, 0x9d, 0x13, 0x4b, - 0x84, 0x04, 0xb8, 0x98, 0x1d, 0xd3, 0x53, 0x25, 0x18, 0x15, 0x18, 0x35, 0x58, 0x83, 0x40, 0x4c, - 0x21, 0x11, 0x2e, 0x56, 0xa7, 0xa2, 0xd4, 0xd4, 0x14, 0x09, 0x26, 0x05, 0x46, 0x0d, 0xce, 0x20, - 0x08, 0x47, 0x48, 0x88, 0x8b, 0xc5, 0x2f, 0x31, 0x37, 0x55, 0x82, 0x19, 0x2c, 0x08, 0x66, 0x27, - 0xb1, 0x81, 0x4d, 0x32, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x5f, 0x95, 0x83, 0x0a, 0x5d, 0x00, - 0x00, 0x00, +func file_proto_test_proto_rawDescGZIP() []byte { + file_proto_test_proto_rawDescOnce.Do(func() { + file_proto_test_proto_rawDescData = protoimpl.X.CompressGZIP(file_proto_test_proto_rawDescData) + }) + return file_proto_test_proto_rawDescData } + +var file_proto_test_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_proto_test_proto_goTypes = []interface{}{ + (*Cat)(nil), // 0: Cat +} +var file_proto_test_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] 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_proto_test_proto_init() } +func file_proto_test_proto_init() { + if File_proto_test_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_proto_test_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Cat); 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_proto_test_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_proto_test_proto_goTypes, + DependencyIndexes: file_proto_test_proto_depIdxs, + MessageInfos: file_proto_test_proto_msgTypes, + }.Build() + File_proto_test_proto = out.File + file_proto_test_proto_rawDesc = nil + file_proto_test_proto_goTypes = nil + file_proto_test_proto_depIdxs = nil +} diff --git a/transport/http/proto/proto_test.go b/transport/http/proto/proto_test.go index 7b59d71..2f1cd17 100644 --- a/transport/http/proto/proto_test.go +++ b/transport/http/proto/proto_test.go @@ -6,7 +6,7 @@ "net/http/httptest" "testing" - "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/proto" ) func TestEncodeProtoRequest(t *testing.T) { diff --git a/transport/http/proto/server.go b/transport/http/proto/server.go index 9990081..a495cb8 100644 --- a/transport/http/proto/server.go +++ b/transport/http/proto/server.go @@ -6,7 +6,7 @@ "net/http" httptransport "github.com/go-kit/kit/transport/http" - "github.com/golang/protobuf/proto" + "google.golang.org/protobuf/proto" ) // EncodeProtoResponse is an EncodeResponseFunc that serializes the response as Protobuf.