From 7f2e0a002cd50fb69c390c7a34de0159c7b064b8 Mon Sep 17 00:00:00 2001 From: "Philip K. Warren" Date: Wed, 26 Aug 2026 12:31:29 -0500 Subject: [PATCH 1/3] Upgrade golangci-lint and go version Build on go 1.26/1.27 and upgrade golangci-lint to the latest version which is compatible with go 1.27. Fix lint issues. --- .github/workflows/ci.yaml | 4 ++-- .golangci.yml | 3 +++ Makefile | 2 +- check/check.go | 2 +- check/check_service_handler_test.go | 19 +++++++++---------- check/checktest/checktest.go | 4 ++-- descriptor/descriptor.go | 2 +- go.mod | 2 +- info/info.go | 2 +- option/option.go | 2 +- option/options.go | 13 ++++++------- 11 files changed, 28 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index c4550e3..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.25.x, 1.26.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.26.x' + if: matrix.go-version == '1.27.x' run: make checkgenerate && make lint diff --git a/.golangci.yml b/.golangci.yml index d20ed67..fa2a18a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -6,9 +6,12 @@ linters: - depguard # unnecessary for small libraries - err113 # way too noisy - exhaustruct # many exceptions + - exhaustruct_v5 # many exceptions - funlen # rely on code review to limit function length - gochecknoglobals # many exceptions - gocognit # dubious "cognitive overhead" quantification + - goconst # many exceptions + - gomodguard # replaced by gomodguard_v2 - inamedparam # not standard style - interfacebloat # many exceptions - ireturn # "accept interfaces, return structs" isn't ironclad diff --git a/Makefile b/Makefile index d05ba97..9c8ae11 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ COPYRIGHT_YEARS := 2024-2025 LICENSE_IGNORE := --ignore testdata/ BUF_VERSION := v1.67.0 -GOLANGCI_LINT_VERSION := v2.11.4 +GOLANGCI_LINT_VERSION := v2.13.1 #GO_GET_PKGS := .PHONY: help diff --git a/check/check.go b/check/check.go index 9569f14..df32759 100644 --- a/check/check.go +++ b/check/check.go @@ -13,4 +13,4 @@ // limitations under the License. // Package check implements the SDK for custom lint and breaking change plugins. -package check // import "buf.build/go/bufplugin/check" +package check diff --git a/check/check_service_handler_test.go b/check/check_service_handler_test.go index fa68c10..74c04ae 100644 --- a/check/check_service_handler_test.go +++ b/check/check_service_handler_test.go @@ -20,7 +20,6 @@ import ( checkv1 "buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go/buf/plugin/check/v1" descriptorv1 "buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go/buf/plugin/descriptor/v1" "github.com/stretchr/testify/require" - "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/descriptorpb" "pluginrpc.com/pluginrpc" ) @@ -43,7 +42,7 @@ func TestCheckServiceHandlerUniqueFiles(t *testing.T) { FileDescriptors: []*descriptorv1.FileDescriptor{ descriptorv1.FileDescriptor_builder{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ - Name: proto.String("foo.proto"), + Name: new("foo.proto"), SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, }, }.Build(), @@ -51,7 +50,7 @@ func TestCheckServiceHandlerUniqueFiles(t *testing.T) { AgainstFileDescriptors: []*descriptorv1.FileDescriptor{ descriptorv1.FileDescriptor_builder{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ - Name: proto.String("foo.proto"), + Name: new("foo.proto"), SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, }, }.Build(), @@ -66,13 +65,13 @@ func TestCheckServiceHandlerUniqueFiles(t *testing.T) { FileDescriptors: []*descriptorv1.FileDescriptor{ descriptorv1.FileDescriptor_builder{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ - Name: proto.String("foo.proto"), + Name: new("foo.proto"), SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, }, }.Build(), descriptorv1.FileDescriptor_builder{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ - Name: proto.String("foo.proto"), + Name: new("foo.proto"), SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, }, }.Build(), @@ -89,7 +88,7 @@ func TestCheckServiceHandlerUniqueFiles(t *testing.T) { FileDescriptors: []*descriptorv1.FileDescriptor{ descriptorv1.FileDescriptor_builder{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ - Name: proto.String("foo.proto"), + Name: new("foo.proto"), SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, }, }.Build(), @@ -97,13 +96,13 @@ func TestCheckServiceHandlerUniqueFiles(t *testing.T) { AgainstFileDescriptors: []*descriptorv1.FileDescriptor{ descriptorv1.FileDescriptor_builder{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ - Name: proto.String("bar.proto"), + Name: new("bar.proto"), SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, }, }.Build(), descriptorv1.FileDescriptor_builder{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ - Name: proto.String("bar.proto"), + Name: new("bar.proto"), SourceCodeInfo: &descriptorpb.SourceCodeInfo{}, }, }.Build(), @@ -133,14 +132,14 @@ func TestCheckServiceHandlerNoSourceCodeInfo(t *testing.T) { FileDescriptors: []*descriptorv1.FileDescriptor{ descriptorv1.FileDescriptor_builder{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ - Name: proto.String("foo.proto"), + Name: new("foo.proto"), }, }.Build(), }, AgainstFileDescriptors: []*descriptorv1.FileDescriptor{ descriptorv1.FileDescriptor_builder{ FileDescriptorProto: &descriptorpb.FileDescriptorProto{ - Name: proto.String("foo.proto"), + Name: new("foo.proto"), }, }.Build(), }, diff --git a/check/checktest/checktest.go b/check/checktest/checktest.go index 82e0038..6bc1b48 100644 --- a/check/checktest/checktest.go +++ b/check/checktest/checktest.go @@ -361,12 +361,12 @@ func compile(ctx context.Context, dirPaths []string, filePaths []string) ([]desc fileDescriptorProto, filePathToUnusedDependencyFilePaths[fileDescriptorProto.GetName()], ) - protoFileDescriptors[i] = descriptorv1.FileDescriptor_builder{ + protoFileDescriptors[i] = &descriptorv1.FileDescriptor{ FileDescriptorProto: fileDescriptorProto, IsImport: !isNotImport, IsSyntaxUnspecified: isSyntaxUnspecified, UnusedDependency: unusedDependencyIndexes, - }.Build() + } } return descriptor.FileDescriptorsForProtoFileDescriptors(protoFileDescriptors) } diff --git a/descriptor/descriptor.go b/descriptor/descriptor.go index f625d7f..06bb4fc 100644 --- a/descriptor/descriptor.go +++ b/descriptor/descriptor.go @@ -13,4 +13,4 @@ // limitations under the License. // Package descriptor provides descriptor types. -package descriptor // import "buf.build/go/bufplugin/descriptor" +package descriptor diff --git a/go.mod b/go.mod index d1ae3ab..3bf1991 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module buf.build/go/bufplugin -go 1.25.0 +go 1.26.0 require ( buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.11-20250718181942-e35f9b667443.1 diff --git a/info/info.go b/info/info.go index 2e68842..57e3460 100644 --- a/info/info.go +++ b/info/info.go @@ -13,4 +13,4 @@ // limitations under the License. // Package info provides plugin information. -package info // import "buf.build/go/bufplugin/info" +package info diff --git a/option/option.go b/option/option.go index a4f7277..a4a6960 100644 --- a/option/option.go +++ b/option/option.go @@ -22,4 +22,4 @@ // limitations under the License. // Package option provides the Options type for plugins. -package option // import "buf.build/go/bufplugin/option" +package option diff --git a/option/options.go b/option/options.go index 7e89f2a..c01390d 100644 --- a/option/options.go +++ b/option/options.go @@ -29,7 +29,6 @@ import ( "reflect" optionv1 "buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go/buf/plugin/option/v1" - "google.golang.org/protobuf/proto" ) // EmptyOptions is an instance of Options with no keys. @@ -271,19 +270,19 @@ func valueToProtoValue(value any) (*optionv1.Value, error) { switch reflectValue := reflect.ValueOf(value); reflectValue.Kind() { case reflect.Bool: return optionv1.Value_builder{ - BoolValue: proto.Bool(reflectValue.Bool()), + BoolValue: new(reflectValue.Bool()), }.Build(), nil case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: return optionv1.Value_builder{ - Int64Value: proto.Int64(reflectValue.Int()), + Int64Value: new(reflectValue.Int()), }.Build(), nil case reflect.Float32, reflect.Float64: return optionv1.Value_builder{ - DoubleValue: proto.Float64(reflectValue.Float()), + DoubleValue: new(reflectValue.Float()), }.Build(), nil case reflect.String: return optionv1.Value_builder{ - StringValue: proto.String(reflectValue.String()), + StringValue: new(reflectValue.String()), }.Build(), nil case reflect.Slice: if t, ok := value.([]byte); ok { @@ -304,7 +303,7 @@ func valueToProtoValue(value any) (*optionv1.Value, error) { Values: values, }.Build(), }.Build(), nil - case reflect.Invalid, reflect.Uintptr, reflect.Complex64, reflect.Complex128, reflect.Array, reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Pointer | reflect.Ptr, reflect.Struct, reflect.UnsafePointer: + case reflect.Invalid, reflect.Uintptr, reflect.Complex64, reflect.Complex128, reflect.Array, reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Pointer, reflect.Struct, reflect.UnsafePointer: return nil, fmt.Errorf("invalid type for Options value %T", value) default: return nil, fmt.Errorf("invalid type for Options value %T", value) @@ -417,7 +416,7 @@ func validateValue(value any) error { } } return nil - case reflect.Invalid, reflect.Uintptr, reflect.Complex64, reflect.Complex128, reflect.Array, reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Pointer | reflect.Ptr, reflect.Struct, reflect.UnsafePointer: + case reflect.Invalid, reflect.Uintptr, reflect.Complex64, reflect.Complex128, reflect.Array, reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Pointer, reflect.Struct, reflect.UnsafePointer: return fmt.Errorf("invalid option value: unhandled type %T", value) default: return fmt.Errorf("invalid option value: unhandled type %T", value) From fe39853ad4e601cf665e6b2866cf1ecb15e5da7a Mon Sep 17 00:00:00 2001 From: "Philip K. Warren" Date: Wed, 26 Aug 2026 12:33:23 -0500 Subject: [PATCH 2/3] revert testing change --- check/checktest/checktest.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/check/checktest/checktest.go b/check/checktest/checktest.go index 6bc1b48..82e0038 100644 --- a/check/checktest/checktest.go +++ b/check/checktest/checktest.go @@ -361,12 +361,12 @@ func compile(ctx context.Context, dirPaths []string, filePaths []string) ([]desc fileDescriptorProto, filePathToUnusedDependencyFilePaths[fileDescriptorProto.GetName()], ) - protoFileDescriptors[i] = &descriptorv1.FileDescriptor{ + protoFileDescriptors[i] = descriptorv1.FileDescriptor_builder{ FileDescriptorProto: fileDescriptorProto, IsImport: !isNotImport, IsSyntaxUnspecified: isSyntaxUnspecified, UnusedDependency: unusedDependencyIndexes, - } + }.Build() } return descriptor.FileDescriptorsForProtoFileDescriptors(protoFileDescriptors) } From 6644daa326c5f87ff0a08bf4eafa53ac270b5067 Mon Sep 17 00:00:00 2001 From: "Philip K. Warren" Date: Wed, 26 Aug 2026 12:35:44 -0500 Subject: [PATCH 3/3] Use same proto version --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 3bf1991..9b13866 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module buf.build/go/bufplugin go 1.26.0 require ( - buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.11-20250718181942-e35f9b667443.1 + buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.12-20260722160903-4d94f3df3a7b.1 buf.build/go/protovalidate v1.1.3 buf.build/go/spdx v0.2.0 github.com/bufbuild/protocompile v0.14.1 diff --git a/go.sum b/go.sum index 643f293..a9bdae1 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.11-20250718181942-e35f9b667443.1 h1:zQ9C3e6FtwSZUFuKAQfpIKGFk5ZuRoGt5g35Bix55sI= -buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.11-20250718181942-e35f9b667443.1/go.mod h1:1Znr6gmYBhbxWUPRrrVnSLXQsz8bvFVw1HHJq2bI3VQ= +buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.12-20260722160903-4d94f3df3a7b.1 h1:ngSJzfqK0bvnKaVhHZ58DTt6nrBiD1IdHDMHAsQQrgM= +buf.build/gen/go/bufbuild/bufplugin/protocolbuffers/go v1.36.12-20260722160903-4d94f3df3a7b.1/go.mod h1:or0FXsDqcJfmWGc8Xx6cr8iAySi3CZ4o0K1+C39pTts= buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.12-20260825204119-511051f7f437.1 h1:Slv0uGxx219srASyiaI5C9cDlyG8kNDcXpTSYcuAeE4= buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.12-20260825204119-511051f7f437.1/go.mod h1:TCt1lluMFnctISJXvkIQ4x3ABrPuUKCWKyjKdkJNBpw= buf.build/gen/go/pluginrpc/pluginrpc/protocolbuffers/go v1.36.12-20241007202033-cf42259fcbfc.1 h1:iXXTQ60veYbSOKfSQHT9Q3TfZxasAgTJcbo2fnNCApE=