From ba0e34add59b0932a5853a93f60823fae3d4e131 Mon Sep 17 00:00:00 2001 From: Edward McFarlane Date: Mon, 3 Feb 2025 17:12:25 +0000 Subject: [PATCH 1/5] Update license file year to include 2025 Signed-off-by: Edward McFarlane --- LICENSE | 2 +- Makefile | 8 ++++---- internal/gen/example/calculator/v1/calculator.pb.go | 2 +- .../v1/calculatorv1connect/calculator.connect.go | 2 +- internal/gen/example/user/v1/user.pb.go | 2 +- .../gen/example/user/v1/userv1connect/user.connect.go | 2 +- internal/proto/example/calculator/v1/calculator.proto | 2 +- internal/proto/example/user/v1/user.proto | 2 +- validate.go | 2 +- validate_test.go | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/LICENSE b/LICENSE index 79cb57f..96ada02 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2023-2024 The Connect Authors + Copyright 2023-2025 The Connect Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/Makefile b/Makefile index 1dd4339..11121da 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ MAKEFLAGS += --no-print-directory BIN := .tmp/bin export PATH := $(BIN):$(PATH) export GOBIN := $(abspath $(BIN)) -COPYRIGHT_YEARS := 2023-2024 +COPYRIGHT_YEARS := 2023-2025 LICENSE_IGNORE := --ignore testdata/ .PHONY: help @@ -70,15 +70,15 @@ checkgenerate: $(BIN)/buf: Makefile @mkdir -p $(@D) - go install github.com/bufbuild/buf/cmd/buf@v1.46.0 + go install github.com/bufbuild/buf/cmd/buf@v1.50.0 $(BIN)/license-header: Makefile @mkdir -p $(@D) - go install github.com/bufbuild/buf/private/pkg/licenseheader/cmd/license-header@v1.46.0 + go install github.com/bufbuild/buf/private/pkg/licenseheader/cmd/license-header@v1.50.0 $(BIN)/golangci-lint: Makefile @mkdir -p $(@D) - go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0 + go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.63.4 $(BIN)/protoc-gen-connect-go: Makefile go.mod @mkdir -p $(@D) diff --git a/internal/gen/example/calculator/v1/calculator.pb.go b/internal/gen/example/calculator/v1/calculator.pb.go index 3759ae6..52ee5f0 100644 --- a/internal/gen/example/calculator/v1/calculator.pb.go +++ b/internal/gen/example/calculator/v1/calculator.pb.go @@ -1,4 +1,4 @@ -// Copyright 2023-2024 The Connect Authors +// Copyright 2023-2025 The Connect Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/internal/gen/example/calculator/v1/calculatorv1connect/calculator.connect.go b/internal/gen/example/calculator/v1/calculatorv1connect/calculator.connect.go index 6a641f2..9b5e5cd 100644 --- a/internal/gen/example/calculator/v1/calculatorv1connect/calculator.connect.go +++ b/internal/gen/example/calculator/v1/calculatorv1connect/calculator.connect.go @@ -1,4 +1,4 @@ -// Copyright 2023-2024 The Connect Authors +// Copyright 2023-2025 The Connect Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/internal/gen/example/user/v1/user.pb.go b/internal/gen/example/user/v1/user.pb.go index df5cd0d..bed0558 100644 --- a/internal/gen/example/user/v1/user.pb.go +++ b/internal/gen/example/user/v1/user.pb.go @@ -1,4 +1,4 @@ -// Copyright 2023-2024 The Connect Authors +// Copyright 2023-2025 The Connect Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/internal/gen/example/user/v1/userv1connect/user.connect.go b/internal/gen/example/user/v1/userv1connect/user.connect.go index fc2ded4..7e6ac62 100644 --- a/internal/gen/example/user/v1/userv1connect/user.connect.go +++ b/internal/gen/example/user/v1/userv1connect/user.connect.go @@ -1,4 +1,4 @@ -// Copyright 2023-2024 The Connect Authors +// Copyright 2023-2025 The Connect Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/internal/proto/example/calculator/v1/calculator.proto b/internal/proto/example/calculator/v1/calculator.proto index 75463fe..fcf635a 100644 --- a/internal/proto/example/calculator/v1/calculator.proto +++ b/internal/proto/example/calculator/v1/calculator.proto @@ -1,4 +1,4 @@ -// Copyright 2023-2024 The Connect Authors +// Copyright 2023-2025 The Connect Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/internal/proto/example/user/v1/user.proto b/internal/proto/example/user/v1/user.proto index 2e75215..5046b1e 100644 --- a/internal/proto/example/user/v1/user.proto +++ b/internal/proto/example/user/v1/user.proto @@ -1,4 +1,4 @@ -// Copyright 2023-2024 The Connect Authors +// Copyright 2023-2025 The Connect Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/validate.go b/validate.go index 65b5d5e..9e87983 100644 --- a/validate.go +++ b/validate.go @@ -1,4 +1,4 @@ -// Copyright 2023-2024 The Connect Authors +// Copyright 2023-2025 The Connect Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/validate_test.go b/validate_test.go index 7e5e6e3..2f9dd71 100644 --- a/validate_test.go +++ b/validate_test.go @@ -1,4 +1,4 @@ -// Copyright 2023-2024 The Connect Authors +// Copyright 2023-2025 The Connect Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. From b4fbce65178e4b8f995c0f0bc3ee86a650c750fd Mon Sep 17 00:00:00 2001 From: Edward McFarlane Date: Mon, 3 Feb 2025 17:18:39 +0000 Subject: [PATCH 2/5] Remove deprecated go lint rules Signed-off-by: Edward McFarlane --- .golangci.yml | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index c9864d2..7fdfaf6 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -26,29 +26,19 @@ linters: disable: - cyclop # covered by gocyclo - depguard # unnecessary for small libraries - - deadcode # abandoned - - exhaustivestruct # replaced by exhaustruct - funlen # rely on code review to limit function length - gocognit # dubious "cognitive overhead" quantification - gofumpt # prefer standard gofmt - goimports # rely on gci instead - - golint # deprecated by Go team - - gomnd # some unnamed constants are okay - - ifshort # deprecated by author - inamedparam # convention is not followed - - interfacer # deprecated by author - ireturn # "accept interfaces, return structs" isn't ironclad - lll # don't want hard limits for line length - maintidx # covered by gocyclo - - maligned # readability trumps efficient struct packing + - mnd # status codes are clearer than constants - nlreturn # generous whitespace violates house style - nonamedreturns # named returns are fine; it's *bare* returns that are bad - - nosnakecase # deprecated in https://github.com/golangci/golangci-lint/pull/3065 - protogetter # too many false positives - - scopelint # deprecated by author - - structcheck # abandoned - testpackage # internal tests are fine - - varcheck # abandoned - wrapcheck # don't _always_ need to wrap errors - wsl # generous whitespace violates house style issues: From be11f045faf2171cd27b1fb1947bc362e25e04c2 Mon Sep 17 00:00:00 2001 From: Edward McFarlane Date: Mon, 3 Feb 2025 17:26:07 +0000 Subject: [PATCH 3/5] Migrate buf.yaml to v2 Signed-off-by: Edward McFarlane --- buf.gen.yaml | 16 +++++++++------- buf.lock | 6 ++++++ buf.work.yaml | 3 --- buf.yaml | 18 ++++++++++++++++++ internal/proto/buf.lock | 8 -------- internal/proto/buf.yaml | 9 --------- 6 files changed, 33 insertions(+), 27 deletions(-) create mode 100644 buf.lock delete mode 100644 buf.work.yaml create mode 100644 buf.yaml delete mode 100644 internal/proto/buf.lock delete mode 100644 internal/proto/buf.yaml diff --git a/buf.gen.yaml b/buf.gen.yaml index 5a56d93..2ad9606 100644 --- a/buf.gen.yaml +++ b/buf.gen.yaml @@ -1,14 +1,16 @@ -version: v1 +version: v2 managed: enabled: true - go_package_prefix: - default: connectrpc.com/validate/internal/gen - except: - - buf.build/bufbuild/protovalidate + disable: + - file_option: go_package + module: buf.build/bufbuild/protovalidate + override: + - file_option: go_package_prefix + value: connectrpc.com/validate/internal/gen plugins: - - plugin: go + - local: protoc-gen-go out: internal/gen opt: paths=source_relative - - plugin: connect-go + - local: protoc-gen-connect-go out: internal/gen opt: paths=source_relative diff --git a/buf.lock b/buf.lock new file mode 100644 index 0000000..7ef24f5 --- /dev/null +++ b/buf.lock @@ -0,0 +1,6 @@ +# Generated by buf. DO NOT EDIT. +version: v2 +deps: + - name: buf.build/bufbuild/protovalidate + commit: b9b8148056b94f6898cc669574bae125 + digest: b5:c592a9051e010e7467dcb8eefcf098ba2ee1be927ea7ac870fa584cca7ca8198e04ed4deb0b973eddde7df42b289f6a077f59ca11d8e8a567d855061a6a97ce4 diff --git a/buf.work.yaml b/buf.work.yaml deleted file mode 100644 index 30f1e1f..0000000 --- a/buf.work.yaml +++ /dev/null @@ -1,3 +0,0 @@ -version: v1 -directories: - - internal/proto diff --git a/buf.yaml b/buf.yaml new file mode 100644 index 0000000..5ecb556 --- /dev/null +++ b/buf.yaml @@ -0,0 +1,18 @@ +version: v2 +modules: + - path: internal/proto +deps: + - buf.build/bufbuild/protovalidate +lint: + use: + - STANDARD + except: + - FIELD_NOT_REQUIRED + - PACKAGE_NO_IMPORT_CYCLE + disallow_comment_ignores: true +breaking: + use: + - FILE + except: + - EXTENSION_NO_DELETE + - FIELD_SAME_DEFAULT diff --git a/internal/proto/buf.lock b/internal/proto/buf.lock deleted file mode 100644 index 18b34be..0000000 --- a/internal/proto/buf.lock +++ /dev/null @@ -1,8 +0,0 @@ -# Generated by buf. DO NOT EDIT. -version: v1 -deps: - - remote: buf.build - owner: bufbuild - repository: protovalidate - commit: b9b8148056b94f6898cc669574bae125 - digest: shake256:5660d7a38dd2ff9a7b8a6304bca6fe798dc6bcd7ecb06c4ce8ebdc0649c2fe969356b90a445a391195fdeae461fbbd9a917dab7687e090465addcb2dbb285b36 diff --git a/internal/proto/buf.yaml b/internal/proto/buf.yaml deleted file mode 100644 index c40753e..0000000 --- a/internal/proto/buf.yaml +++ /dev/null @@ -1,9 +0,0 @@ -version: v1 -deps: - - buf.build/bufbuild/protovalidate -breaking: - use: - - FILE -lint: - use: - - DEFAULT From 05e30c5538e0208871bd963bdad5b90b9e9631d4 Mon Sep 17 00:00:00 2001 From: Edward McFarlane Date: Mon, 3 Feb 2025 17:28:13 +0000 Subject: [PATCH 4/5] Upgrade connect-go version and generated code Signed-off-by: Edward McFarlane --- .golangci.yml | 1 - go.mod | 2 +- go.sum | 2 ++ .../v1/calculatorv1connect/calculator.connect.go | 12 ++++-------- .../example/user/v1/userv1connect/user.connect.go | 12 ++++-------- 5 files changed, 11 insertions(+), 18 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 7fdfaf6..03e163c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -34,7 +34,6 @@ linters: - ireturn # "accept interfaces, return structs" isn't ironclad - lll # don't want hard limits for line length - maintidx # covered by gocyclo - - mnd # status codes are clearer than constants - nlreturn # generous whitespace violates house style - nonamedreturns # named returns are fine; it's *bare* returns that are bad - protogetter # too many false positives diff --git a/go.mod b/go.mod index dc7817d..04f3d34 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.21.1 require ( buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.4-20250130201111-63bb56e20495.1 - connectrpc.com/connect v1.17.0 + connectrpc.com/connect v1.18.1 github.com/bufbuild/protovalidate-go v0.9.1 github.com/stretchr/testify v1.10.0 google.golang.org/protobuf v1.36.4 diff --git a/go.sum b/go.sum index a00ee1d..74ebf27 100644 --- a/go.sum +++ b/go.sum @@ -4,6 +4,8 @@ cel.dev/expr v0.19.1 h1:NciYrtDRIR0lNCnH1LFJegdjspNx9fI59O7TWcua/W4= cel.dev/expr v0.19.1/go.mod h1:MrpN08Q+lEBs+bGYdLxxHkZoUSsCp0nSKTs0nTymJgw= connectrpc.com/connect v1.17.0 h1:W0ZqMhtVzn9Zhn2yATuUokDLO5N+gIuBWMOnsQrfmZk= connectrpc.com/connect v1.17.0/go.mod h1:0292hj1rnx8oFrStN7cB4jjVBeqs+Yx5yDIC2prWDO8= +connectrpc.com/connect v1.18.1 h1:PAg7CjSAGvscaf6YZKUefjoih5Z/qYkyaTrBW8xvYPw= +connectrpc.com/connect v1.18.1/go.mod h1:0292hj1rnx8oFrStN7cB4jjVBeqs+Yx5yDIC2prWDO8= github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI= github.com/antlr4-go/antlr/v4 v4.13.0/go.mod h1:pfChB/xh/Unjila75QW7+VU4TSnWnnk9UTnmpPaOR2g= github.com/bufbuild/protovalidate-go v0.9.1 h1:cdrIA33994yCcJyEIZRL36ZGTe9UDM/WHs5MBHEimiE= diff --git a/internal/gen/example/calculator/v1/calculatorv1connect/calculator.connect.go b/internal/gen/example/calculator/v1/calculatorv1connect/calculator.connect.go index 9b5e5cd..20d6cb7 100644 --- a/internal/gen/example/calculator/v1/calculatorv1connect/calculator.connect.go +++ b/internal/gen/example/calculator/v1/calculatorv1connect/calculator.connect.go @@ -52,12 +52,6 @@ const ( CalculatorServiceCumSumProcedure = "/example.calculator.v1.CalculatorService/CumSum" ) -// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. -var ( - calculatorServiceServiceDescriptor = v1.File_example_calculator_v1_calculator_proto.Services().ByName("CalculatorService") - calculatorServiceCumSumMethodDescriptor = calculatorServiceServiceDescriptor.Methods().ByName("CumSum") -) - // CalculatorServiceClient is a client for the example.calculator.v1.CalculatorService service. type CalculatorServiceClient interface { CumSum(context.Context) *connect.BidiStreamForClient[v1.CumSumRequest, v1.CumSumResponse] @@ -72,11 +66,12 @@ type CalculatorServiceClient interface { // http://api.acme.com or https://acme.com/grpc). func NewCalculatorServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) CalculatorServiceClient { baseURL = strings.TrimRight(baseURL, "/") + calculatorServiceMethods := v1.File_example_calculator_v1_calculator_proto.Services().ByName("CalculatorService").Methods() return &calculatorServiceClient{ cumSum: connect.NewClient[v1.CumSumRequest, v1.CumSumResponse]( httpClient, baseURL+CalculatorServiceCumSumProcedure, - connect.WithSchema(calculatorServiceCumSumMethodDescriptor), + connect.WithSchema(calculatorServiceMethods.ByName("CumSum")), connect.WithClientOptions(opts...), ), } @@ -104,10 +99,11 @@ type CalculatorServiceHandler interface { // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf // and JSON codecs. They also support gzip compression. func NewCalculatorServiceHandler(svc CalculatorServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + calculatorServiceMethods := v1.File_example_calculator_v1_calculator_proto.Services().ByName("CalculatorService").Methods() calculatorServiceCumSumHandler := connect.NewBidiStreamHandler( CalculatorServiceCumSumProcedure, svc.CumSum, - connect.WithSchema(calculatorServiceCumSumMethodDescriptor), + connect.WithSchema(calculatorServiceMethods.ByName("CumSum")), connect.WithHandlerOptions(opts...), ) return "/example.calculator.v1.CalculatorService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { diff --git a/internal/gen/example/user/v1/userv1connect/user.connect.go b/internal/gen/example/user/v1/userv1connect/user.connect.go index 7e6ac62..0b895e4 100644 --- a/internal/gen/example/user/v1/userv1connect/user.connect.go +++ b/internal/gen/example/user/v1/userv1connect/user.connect.go @@ -51,12 +51,6 @@ const ( UserServiceCreateUserProcedure = "/example.user.v1.UserService/CreateUser" ) -// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. -var ( - userServiceServiceDescriptor = v1.File_example_user_v1_user_proto.Services().ByName("UserService") - userServiceCreateUserMethodDescriptor = userServiceServiceDescriptor.Methods().ByName("CreateUser") -) - // UserServiceClient is a client for the example.user.v1.UserService service. type UserServiceClient interface { CreateUser(context.Context, *connect.Request[v1.CreateUserRequest]) (*connect.Response[v1.CreateUserResponse], error) @@ -71,11 +65,12 @@ type UserServiceClient interface { // http://api.acme.com or https://acme.com/grpc). func NewUserServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) UserServiceClient { baseURL = strings.TrimRight(baseURL, "/") + userServiceMethods := v1.File_example_user_v1_user_proto.Services().ByName("UserService").Methods() return &userServiceClient{ createUser: connect.NewClient[v1.CreateUserRequest, v1.CreateUserResponse]( httpClient, baseURL+UserServiceCreateUserProcedure, - connect.WithSchema(userServiceCreateUserMethodDescriptor), + connect.WithSchema(userServiceMethods.ByName("CreateUser")), connect.WithClientOptions(opts...), ), } @@ -102,10 +97,11 @@ type UserServiceHandler interface { // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf // and JSON codecs. They also support gzip compression. func NewUserServiceHandler(svc UserServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + userServiceMethods := v1.File_example_user_v1_user_proto.Services().ByName("UserService").Methods() userServiceCreateUserHandler := connect.NewUnaryHandler( UserServiceCreateUserProcedure, svc.CreateUser, - connect.WithSchema(userServiceCreateUserMethodDescriptor), + connect.WithSchema(userServiceMethods.ByName("CreateUser")), connect.WithHandlerOptions(opts...), ) return "/example.user.v1.UserService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { From 1340b9730876bdefe270b36c645b156d59d3e43d Mon Sep 17 00:00:00 2001 From: Edward McFarlane Date: Mon, 3 Feb 2025 17:38:40 +0000 Subject: [PATCH 5/5] Remove unneeded buf lint exceptions Signed-off-by: Edward McFarlane --- buf.yaml | 6 ------ go.sum | 2 -- 2 files changed, 8 deletions(-) diff --git a/buf.yaml b/buf.yaml index 5ecb556..7607431 100644 --- a/buf.yaml +++ b/buf.yaml @@ -6,13 +6,7 @@ deps: lint: use: - STANDARD - except: - - FIELD_NOT_REQUIRED - - PACKAGE_NO_IMPORT_CYCLE disallow_comment_ignores: true breaking: use: - FILE - except: - - EXTENSION_NO_DELETE - - FIELD_SAME_DEFAULT diff --git a/go.sum b/go.sum index 74ebf27..b5f9f92 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,6 @@ buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.4-2025013020111 buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.36.4-20250130201111-63bb56e20495.1/go.mod h1:novQBstnxcGpfKf8qGRATqn1anQKwMJIbH5Q581jibU= cel.dev/expr v0.19.1 h1:NciYrtDRIR0lNCnH1LFJegdjspNx9fI59O7TWcua/W4= cel.dev/expr v0.19.1/go.mod h1:MrpN08Q+lEBs+bGYdLxxHkZoUSsCp0nSKTs0nTymJgw= -connectrpc.com/connect v1.17.0 h1:W0ZqMhtVzn9Zhn2yATuUokDLO5N+gIuBWMOnsQrfmZk= -connectrpc.com/connect v1.17.0/go.mod h1:0292hj1rnx8oFrStN7cB4jjVBeqs+Yx5yDIC2prWDO8= connectrpc.com/connect v1.18.1 h1:PAg7CjSAGvscaf6YZKUefjoih5Z/qYkyaTrBW8xvYPw= connectrpc.com/connect v1.18.1/go.mod h1:0292hj1rnx8oFrStN7cB4jjVBeqs+Yx5yDIC2prWDO8= github.com/antlr4-go/antlr/v4 v4.13.0 h1:lxCg3LAv+EUK6t1i0y1V6/SLeUi0eKEKdhQAlS8TVTI=