diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9c921f8..8c19c0b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go-version: [1.22.x, 1.23.x] + go-version: [1.26.x, 1.27.x] steps: - name: Checkout Code uses: actions/checkout@v7 @@ -32,5 +32,5 @@ jobs: # conflicting guidance, run only on the most recent supported version. # For the same reason, only check generated code on the most recent # supported version. - if: matrix.go-version == '1.23.x' + if: matrix.go-version == '1.27.x' run: make checkgenerate && make lint diff --git a/.golangci.yml b/.golangci.yml index 0c51107..14d4be5 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,62 +1,93 @@ -linters-settings: - errcheck: - check-type-assertions: true - forbidigo: - forbid: - - '^fmt\.Print' - - '^log\.' - - '^print$' - - '^println$' - - '^panic$' - godox: - # TODO, OPT, etc. comments are fine to commit. Use FIXME comments for - # temporary hacks, and use godox to prevent committing them. - keywords: [FIXME] - varnamelen: - ignore-decls: - - T any - - i int - - wg sync.WaitGroup - - sb strings.Builder +version: "2" linters: - enable-all: true + default: all disable: - cyclop # covered by gocyclo - depguard # unnecessary for small libraries - err113 # dubious dynamic errors warnings + - exhaustive # many exceptions - exhaustruct # many exceptions + - exhaustruct_v5 # many exceptions - funlen # rely on code review to limit function length - gochecknoglobals # many exceptions - gocognit # dubious "cognitive overhead" quantification - - gofumpt # prefer standard gofmt - - goimports # rely on gci instead - - gomnd # some unnamed constants are okay + - gomodguard # replaced by gomodguard_v2 - ireturn # "accept interfaces, return structs" isn't ironclad - lll # don't want hard limits for line length - maintidx # covered by gocyclo + - mnd # some unnamed constants are okay - nilnil # we allow this + - noinlineerr # excess scope violates house style - nlreturn # generous whitespace violates house style - tagalign # false positives - testpackage # internal tests are fine - thelper # we want to print out the whole stack - wrapcheck # don't _always_ need to wrap errors - wsl # generous whitespace violates house style -issues: - exclude-dirs-use-default: false - exclude-rules: - - linters: - - varnamelen - - goconst - path: cmd/protoc-gen-pluginrpc-go/main.go - - linters: - - varnamelen - path: pluginrpc_test.go - - linters: - - gosec - path: runner.go - - linters: - - gocritic - path: server.go - - linters: - - nestif - path: wire.go + - wsl_v5 # generous whitespace violates house style + settings: + errcheck: + check-type-assertions: true + forbidigo: + forbid: + - pattern: ^fmt\.Print + - pattern: ^log\. + - pattern: ^print$ + - pattern: ^println$ + - pattern: ^panic$ + godox: + # TODO, OPT, etc. comments are fine to commit. Use FIXME comments for + # temporary hacks, and use godox to prevent committing them. + keywords: + - FIXME + varnamelen: + ignore-decls: + - T any + - i int + - wg sync.WaitGroup + - sb strings.Builder + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + rules: + - linters: + - goconst + - prealloc + - varnamelen + path: cmd/protoc-gen-pluginrpc-go/main.go + - linters: + - varnamelen + path: pluginrpc_test.go + - linters: + - gosec + path: runner.go + - linters: + - gosec + path: code.go + text: "G115:" + - linters: + - gosec + path: internal/example/cmd/echo-plugin/main.go + text: "G115:" + - linters: + - gosec + path: pluginrpc_test.go + text: "G115:" + - linters: + - gocritic + path: server.go + - linters: + - nestif + path: wire.go +formatters: + # gofumpt is not enabled: prefer standard gofmt. + # goimports is not enabled: rely on gci instead. + enable: + - gci + - gofmt + exclusions: + generated: lax diff --git a/Makefile b/Makefile index 238b4e0..4710a47 100644 --- a/Makefile +++ b/Makefile @@ -13,8 +13,8 @@ COPYRIGHT_YEARS := 2024 LICENSE_IGNORE := --ignore /testdata/ BUF_VERSION := v1.42.0 -GO_MOD_GOTOOLCHAIN := go1.23.1 -GOLANGCI_LINT_VERSION := v1.60.1 +GO_MOD_GOTOOLCHAIN := go1.27.1 +GOLANGCI_LINT_VERSION := v2.14.0 # https://github.com/golangci/golangci-lint/issues/4837 GOLANGCI_LINT_GOTOOLCHAIN := $(GO_MOD_GOTOOLCHAIN) @@ -85,7 +85,7 @@ $(BIN)/license-header: Makefile $(BIN)/golangci-lint: Makefile @mkdir -p $(@D) - GOTOOLCHAIN=$(GOLANGCI_LINT_GOTOOLCHAIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) + GOTOOLCHAIN=$(GOLANGCI_LINT_GOTOOLCHAIN) go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION) $(BIN)/protoc-gen-go: Makefile go.mod @mkdir -p $(@D) diff --git a/cmd/protoc-gen-pluginrpc-go/main.go b/cmd/protoc-gen-pluginrpc-go/main.go index 8f632c2..05ce430 100644 --- a/cmd/protoc-gen-pluginrpc-go/main.go +++ b/cmd/protoc-gen-pluginrpc-go/main.go @@ -619,7 +619,7 @@ func getStreamingMethodsForService(service *protogen.Service) []*protogen.Method } func isUnaryMethod(method *protogen.Method) bool { - return !(method.Desc.IsStreamingClient() || method.Desc.IsStreamingServer()) + return !method.Desc.IsStreamingClient() && !method.Desc.IsStreamingServer() } // Raggedy comments in the generated code are driving me insane. This diff --git a/error.go b/error.go index 1f85abf..476f228 100644 --- a/error.go +++ b/error.go @@ -47,7 +47,7 @@ func NewError(code Code, underlying error) *Error { } // NewErrorf returns a new Error. - +// // Code and a non-empty message are required. // // An Error will never have an invalid Code or nil underlying error diff --git a/go.mod b/go.mod index 4d9a5df..8fdd7ab 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module pluginrpc.com/pluginrpc -go 1.23 - -toolchain go1.23.0 +go 1.26 require ( buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.36.12-20241007202033-cf42259fcbfc.2 diff --git a/internal/example/gen/pluginrpc/example/v1/example.pb.go b/internal/example/gen/pluginrpc/example/v1/example.pb.go index bc22287..2723252 100644 --- a/internal/example/gen/pluginrpc/example/v1/example.pb.go +++ b/internal/example/gen/pluginrpc/example/v1/example.pb.go @@ -14,7 +14,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.34.2 +// protoc-gen-go v1.36.12 // protoc (unknown) // source: pluginrpc/example/v1/example.proto @@ -26,6 +26,7 @@ import ( protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + unsafe "unsafe" ) const ( @@ -37,21 +38,18 @@ const ( // A request to echo the given message. type EchoRequestRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The message to echo back. - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *EchoRequestRequest) Reset() { *x = EchoRequestRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_pluginrpc_example_v1_example_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_pluginrpc_example_v1_example_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *EchoRequestRequest) String() string { @@ -62,7 +60,7 @@ func (*EchoRequestRequest) ProtoMessage() {} func (x *EchoRequestRequest) ProtoReflect() protoreflect.Message { mi := &file_pluginrpc_example_v1_example_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -86,21 +84,18 @@ func (x *EchoRequestRequest) GetMessage() string { // A response to echo. type EchoRequestResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The echoed message. - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *EchoRequestResponse) Reset() { *x = EchoRequestResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_pluginrpc_example_v1_example_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_pluginrpc_example_v1_example_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *EchoRequestResponse) String() string { @@ -111,7 +106,7 @@ func (*EchoRequestResponse) ProtoMessage() {} func (x *EchoRequestResponse) ProtoReflect() protoreflect.Message { mi := &file_pluginrpc_example_v1_example_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -135,23 +130,20 @@ func (x *EchoRequestResponse) GetMessage() string { // An error to echo back. type EchoErrorRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The error code to return as part of the error. Code v1.Code `protobuf:"varint,1,opt,name=code,proto3,enum=pluginrpc.v1.Code" json:"code,omitempty"` // The error message to return as part of the error. - Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` + Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *EchoErrorRequest) Reset() { *x = EchoErrorRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_pluginrpc_example_v1_example_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_pluginrpc_example_v1_example_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *EchoErrorRequest) String() string { @@ -162,7 +154,7 @@ func (*EchoErrorRequest) ProtoMessage() {} func (x *EchoErrorRequest) ProtoReflect() protoreflect.Message { mi := &file_pluginrpc_example_v1_example_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -193,18 +185,16 @@ func (x *EchoErrorRequest) GetMessage() string { // A blank response. type EchoErrorResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *EchoErrorResponse) Reset() { *x = EchoErrorResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_pluginrpc_example_v1_example_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_pluginrpc_example_v1_example_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *EchoErrorResponse) String() string { @@ -215,7 +205,7 @@ func (*EchoErrorResponse) ProtoMessage() {} func (x *EchoErrorResponse) ProtoReflect() protoreflect.Message { mi := &file_pluginrpc_example_v1_example_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -233,18 +223,16 @@ func (*EchoErrorResponse) Descriptor() ([]byte, []int) { // A request to echo a static list back The request is purposefully // empty to demonstrate how pluginrpc works with empty requests. type EchoListRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *EchoListRequest) Reset() { *x = EchoListRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_pluginrpc_example_v1_example_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_pluginrpc_example_v1_example_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *EchoListRequest) String() string { @@ -255,7 +243,7 @@ func (*EchoListRequest) ProtoMessage() {} func (x *EchoListRequest) ProtoReflect() protoreflect.Message { mi := &file_pluginrpc_example_v1_example_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -272,21 +260,18 @@ func (*EchoListRequest) Descriptor() ([]byte, []int) { // A response that will always contain the list ["foo", "bar"]. type EchoListResponse struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - + state protoimpl.MessageState `protogen:"open.v1"` // The list that will always be ["foo", "bar"]. - List []string `protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"` + List []string `protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *EchoListResponse) Reset() { *x = EchoListResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_pluginrpc_example_v1_example_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_pluginrpc_example_v1_example_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *EchoListResponse) String() string { @@ -297,7 +282,7 @@ func (*EchoListResponse) ProtoMessage() {} func (x *EchoListResponse) ProtoReflect() protoreflect.Message { mi := &file_pluginrpc_example_v1_example_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { + if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { ms.StoreMessageInfo(mi) @@ -321,73 +306,34 @@ func (x *EchoListResponse) GetList() []string { var File_pluginrpc_example_v1_example_proto protoreflect.FileDescriptor -var file_pluginrpc_example_v1_example_proto_rawDesc = []byte{ - 0x0a, 0x22, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x72, 0x70, 0x63, 0x2f, 0x65, 0x78, 0x61, 0x6d, - 0x70, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x14, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x72, 0x70, 0x63, 0x2e, - 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x1a, 0x1c, 0x70, 0x6c, 0x75, 0x67, - 0x69, 0x6e, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x31, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x72, - 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2e, 0x0a, 0x12, 0x45, 0x63, 0x68, 0x6f, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x18, - 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x2f, 0x0a, 0x13, 0x45, 0x63, 0x68, 0x6f, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, - 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x54, 0x0a, 0x10, 0x45, 0x63, 0x68, - 0x6f, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x26, 0x0a, - 0x04, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x70, 0x6c, - 0x75, 0x67, 0x69, 0x6e, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x64, 0x65, 0x52, - 0x04, 0x63, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, - 0x13, 0x0a, 0x11, 0x45, 0x63, 0x68, 0x6f, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, - 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x11, 0x0a, 0x0f, 0x45, 0x63, 0x68, 0x6f, 0x4c, 0x69, 0x73, 0x74, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x26, 0x0a, 0x10, 0x45, 0x63, 0x68, 0x6f, 0x4c, - 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6c, - 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x32, - 0xaa, 0x02, 0x0a, 0x0b, 0x45, 0x63, 0x68, 0x6f, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, - 0x62, 0x0a, 0x0b, 0x45, 0x63, 0x68, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x28, - 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x72, 0x70, 0x63, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, - 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x63, 0x68, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, - 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, - 0x6e, 0x72, 0x70, 0x63, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, - 0x45, 0x63, 0x68, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x5c, 0x0a, 0x09, 0x45, 0x63, 0x68, 0x6f, 0x45, 0x72, 0x72, 0x6f, 0x72, - 0x12, 0x26, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x72, 0x70, 0x63, 0x2e, 0x65, 0x78, 0x61, - 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x63, 0x68, 0x6f, 0x45, 0x72, 0x72, 0x6f, - 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x27, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, - 0x6e, 0x72, 0x70, 0x63, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, - 0x45, 0x63, 0x68, 0x6f, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x59, 0x0a, 0x08, 0x45, 0x63, 0x68, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x25, 0x2e, - 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x72, 0x70, 0x63, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, - 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x63, 0x68, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x26, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x72, 0x70, 0x63, - 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x63, 0x68, 0x6f, - 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0xe7, 0x01, 0x0a, - 0x18, 0x63, 0x6f, 0x6d, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x72, 0x70, 0x63, 0x2e, 0x65, - 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2e, 0x76, 0x31, 0x42, 0x0c, 0x45, 0x78, 0x61, 0x6d, 0x70, - 0x6c, 0x65, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x4b, 0x70, 0x6c, 0x75, 0x67, 0x69, - 0x6e, 0x72, 0x70, 0x63, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x72, - 0x70, 0x63, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x65, 0x78, 0x61, 0x6d, - 0x70, 0x6c, 0x65, 0x2f, 0x67, 0x65, 0x6e, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x72, 0x70, - 0x63, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x65, 0x78, 0x61, - 0x6d, 0x70, 0x6c, 0x65, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x50, 0x45, 0x58, 0xaa, 0x02, 0x14, 0x50, - 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x72, 0x70, 0x63, 0x2e, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, - 0x2e, 0x56, 0x31, 0xca, 0x02, 0x14, 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x72, 0x70, 0x63, 0x5c, - 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5c, 0x56, 0x31, 0xe2, 0x02, 0x20, 0x50, 0x6c, 0x75, - 0x67, 0x69, 0x6e, 0x72, 0x70, 0x63, 0x5c, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x5c, 0x56, - 0x31, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x16, - 0x50, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x72, 0x70, 0x63, 0x3a, 0x3a, 0x45, 0x78, 0x61, 0x6d, 0x70, - 0x6c, 0x65, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} +const file_pluginrpc_example_v1_example_proto_rawDesc = "" + + "\n" + + "\"pluginrpc/example/v1/example.proto\x12\x14pluginrpc.example.v1\x1a\x1cpluginrpc/v1/pluginrpc.proto\".\n" + + "\x12EchoRequestRequest\x12\x18\n" + + "\amessage\x18\x01 \x01(\tR\amessage\"/\n" + + "\x13EchoRequestResponse\x12\x18\n" + + "\amessage\x18\x01 \x01(\tR\amessage\"T\n" + + "\x10EchoErrorRequest\x12&\n" + + "\x04code\x18\x01 \x01(\x0e2\x12.pluginrpc.v1.CodeR\x04code\x12\x18\n" + + "\amessage\x18\x02 \x01(\tR\amessage\"\x13\n" + + "\x11EchoErrorResponse\"\x11\n" + + "\x0fEchoListRequest\"&\n" + + "\x10EchoListResponse\x12\x12\n" + + "\x04list\x18\x01 \x03(\tR\x04list2\xaa\x02\n" + + "\vEchoService\x12b\n" + + "\vEchoRequest\x12(.pluginrpc.example.v1.EchoRequestRequest\x1a).pluginrpc.example.v1.EchoRequestResponse\x12\\\n" + + "\tEchoError\x12&.pluginrpc.example.v1.EchoErrorRequest\x1a'.pluginrpc.example.v1.EchoErrorResponse\x12Y\n" + + "\bEchoList\x12%.pluginrpc.example.v1.EchoListRequest\x1a&.pluginrpc.example.v1.EchoListResponseB\xe7\x01\n" + + "\x18com.pluginrpc.example.v1B\fExampleProtoP\x01ZKpluginrpc.com/pluginrpc/internal/example/gen/pluginrpc/example/v1;examplev1\xa2\x02\x03PEX\xaa\x02\x14Pluginrpc.Example.V1\xca\x02\x14Pluginrpc\\Example\\V1\xe2\x02 Pluginrpc\\Example\\V1\\GPBMetadata\xea\x02\x16Pluginrpc::Example::V1b\x06proto3" var ( file_pluginrpc_example_v1_example_proto_rawDescOnce sync.Once - file_pluginrpc_example_v1_example_proto_rawDescData = file_pluginrpc_example_v1_example_proto_rawDesc + file_pluginrpc_example_v1_example_proto_rawDescData []byte ) func file_pluginrpc_example_v1_example_proto_rawDescGZIP() []byte { file_pluginrpc_example_v1_example_proto_rawDescOnce.Do(func() { - file_pluginrpc_example_v1_example_proto_rawDescData = protoimpl.X.CompressGZIP(file_pluginrpc_example_v1_example_proto_rawDescData) + file_pluginrpc_example_v1_example_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_pluginrpc_example_v1_example_proto_rawDesc), len(file_pluginrpc_example_v1_example_proto_rawDesc))) }) return file_pluginrpc_example_v1_example_proto_rawDescData } @@ -422,85 +368,11 @@ func file_pluginrpc_example_v1_example_proto_init() { if File_pluginrpc_example_v1_example_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_pluginrpc_example_v1_example_proto_msgTypes[0].Exporter = func(v any, i int) any { - switch v := v.(*EchoRequestRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pluginrpc_example_v1_example_proto_msgTypes[1].Exporter = func(v any, i int) any { - switch v := v.(*EchoRequestResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pluginrpc_example_v1_example_proto_msgTypes[2].Exporter = func(v any, i int) any { - switch v := v.(*EchoErrorRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pluginrpc_example_v1_example_proto_msgTypes[3].Exporter = func(v any, i int) any { - switch v := v.(*EchoErrorResponse); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pluginrpc_example_v1_example_proto_msgTypes[4].Exporter = func(v any, i int) any { - switch v := v.(*EchoListRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_pluginrpc_example_v1_example_proto_msgTypes[5].Exporter = func(v any, i int) any { - switch v := v.(*EchoListResponse); 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_pluginrpc_example_v1_example_proto_rawDesc, + RawDescriptor: unsafe.Slice(unsafe.StringData(file_pluginrpc_example_v1_example_proto_rawDesc), len(file_pluginrpc_example_v1_example_proto_rawDesc)), NumEnums: 0, NumMessages: 6, NumExtensions: 0, @@ -511,7 +383,6 @@ func file_pluginrpc_example_v1_example_proto_init() { MessageInfos: file_pluginrpc_example_v1_example_proto_msgTypes, }.Build() File_pluginrpc_example_v1_example_proto = out.File - file_pluginrpc_example_v1_example_proto_rawDesc = nil file_pluginrpc_example_v1_example_proto_goTypes = nil file_pluginrpc_example_v1_example_proto_depIdxs = nil } diff --git a/pluginrpc.go b/pluginrpc.go index db472da..41215cf 100644 --- a/pluginrpc.go +++ b/pluginrpc.go @@ -13,7 +13,7 @@ // limitations under the License. // Package pluginrpc implements an RPC framework for plugins. -package pluginrpc // import "pluginrpc.com/pluginrpc" +package pluginrpc const ( // Version is the semantic version of the pluginrpc module. diff --git a/pluginrpc_test.go b/pluginrpc_test.go index 75611e8..699606d 100644 --- a/pluginrpc_test.go +++ b/pluginrpc_test.go @@ -63,7 +63,7 @@ func TestEchoRequestNil(t *testing.T) { response, err := echoServiceClient.EchoRequest(context.Background(), nil) require.NoError(t, err) require.NotNil(t, response) - require.Equal(t, "", response.GetMessage()) + require.Empty(t, response.GetMessage()) }, ) } @@ -130,9 +130,7 @@ func TestUnimplemented(t *testing.T) { func forEachDimension(t *testing.T, f func(*testing.T, pluginrpc.Client)) { for _, format := range allTestFormats { for j, newClient := range []func(...pluginrpc.ClientOption) (pluginrpc.Client, error){newExecRunnerClient, newServerRunnerClient} { - j := j format := format - newClient := newClient t.Run( format.String()+strconv.Itoa(j), func(t *testing.T) {