diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 847b8a5..4bc0dc7 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.20.x, 1.21.x, 1.22.x] + go-version: [1.21.x, 1.22.x, 1.23.x] steps: - name: Checkout Code uses: actions/checkout@v4 @@ -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.22.x' + if: matrix.go-version == '1.23.x' run: make checkgenerate && make lint diff --git a/.golangci.yml b/.golangci.yml index 170e2c8..c9864d2 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,5 +1,3 @@ -run: - skip-dirs-use-default: false linters-settings: errcheck: check-type-assertions: true @@ -57,4 +55,4 @@ issues: exclude: # Don't ban use of fmt.Errorf to create new errors, but the remaining # checks from err113 are useful. - - "err113: do not define dynamic errors.*" + - "do not define dynamic errors, use wrapped static errors instead: .*" diff --git a/Makefile b/Makefile index 5d871a2..1dd4339 100644 --- a/Makefile +++ b/Makefile @@ -70,15 +70,15 @@ checkgenerate: $(BIN)/buf: Makefile @mkdir -p $(@D) - go install github.com/bufbuild/buf/cmd/buf@v1.29.0 + go install github.com/bufbuild/buf/cmd/buf@v1.46.0 $(BIN)/license-header: Makefile @mkdir -p $(@D) - go install github.com/bufbuild/buf/private/pkg/licenseheader/cmd/license-header@v1.29.0 + go install github.com/bufbuild/buf/private/pkg/licenseheader/cmd/license-header@v1.46.0 $(BIN)/golangci-lint: Makefile @mkdir -p $(@D) - go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.2 + go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0 $(BIN)/protoc-gen-connect-go: Makefile go.mod @mkdir -p $(@D) diff --git a/go.mod b/go.mod index bdbf6dc..86dff8e 100644 --- a/go.mod +++ b/go.mod @@ -1,25 +1,24 @@ module connectrpc.com/validate -go 1.20 +go 1.21.0 require ( - buf.build/gen/go/bufbuild/protovalidate-testing/protocolbuffers/go v1.31.0-20230824200732-8bc04916caea.1 - buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.31.0-20230824200731-b9b8148056b9.1 - connectrpc.com/connect v1.11.0 - github.com/bufbuild/protovalidate-go v0.3.0 - github.com/stretchr/testify v1.8.4 - google.golang.org/protobuf v1.31.0 + buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.35.1-20240920164238-5a7b106cbb87.1 + connectrpc.com/connect v1.17.0 + github.com/bufbuild/protovalidate-go v0.7.2 + github.com/stretchr/testify v1.9.0 + google.golang.org/protobuf v1.35.1 ) require ( - github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230512164433-5d1fd1a340c9 // indirect + github.com/antlr4-go/antlr/v4 v4.13.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/google/cel-go v0.17.4 // indirect + github.com/google/cel-go v0.21.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/stoewer/go-strcase v1.3.0 // indirect - golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 // indirect - golang.org/x/text v0.10.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc // indirect + golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect + golang.org/x/text v0.16.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index b7e09d0..c56e4a3 100644 --- a/go.sum +++ b/go.sum @@ -1,24 +1,24 @@ -buf.build/gen/go/bufbuild/protovalidate-testing/protocolbuffers/go v1.31.0-20230824200732-8bc04916caea.1 h1:wWsaA01KC5hgoW4oHFiGzEqMmgcE7UyU43F8AJrex1U= -buf.build/gen/go/bufbuild/protovalidate-testing/protocolbuffers/go v1.31.0-20230824200732-8bc04916caea.1/go.mod h1:cJ4gQkiW4uPTUTI3+O2862OzMSTnzrFNwMauHLwPDPg= -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.31.0-20230824200731-b9b8148056b9.1 h1:9Ea7lsYYvoyqmq79GbCy6POXHrZbC+pHs+6lGNx9IBQ= -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.31.0-20230824200731-b9b8148056b9.1/go.mod h1:xafc+XIsTxTy76GJQ1TKgvJWsSugFBqMaN27WhUblew= -connectrpc.com/connect v1.11.0 h1:Av2KQXxSaX4vjqhf5Cl01SX4dqYADQ38eBtr84JSUBk= -connectrpc.com/connect v1.11.0/go.mod h1:3AGaO6RRGMx5IKFfqbe3hvK1NqLosFNP2BxDYTPmNPo= -github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230512164433-5d1fd1a340c9 h1:goHVqTbFX3AIo0tzGr14pgfAW2ZfPChKO21Z9MGf/gk= -github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230512164433-5d1fd1a340c9/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM= -github.com/bufbuild/protovalidate-go v0.3.0 h1:t9zKgM//9VtPnP0TvyFqWubLQtSbwLwEUVOxgtX9/os= -github.com/bufbuild/protovalidate-go v0.3.0/go.mod h1:4mZkDYMGJlnHHQ9rPOhVEZ4bA13iOJBRLzywxy8f/lo= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.35.1-20240920164238-5a7b106cbb87.1 h1:9wP6ZZYWnF2Z0TxmII7m3XNykxnP4/w8oXeth6ekcRI= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.35.1-20240920164238-5a7b106cbb87.1/go.mod h1:Duw/9JoXkXIydyASnLYIiufkzySThoqavOsF+IihqvM= +connectrpc.com/connect v1.17.0 h1:W0ZqMhtVzn9Zhn2yATuUokDLO5N+gIuBWMOnsQrfmZk= +connectrpc.com/connect v1.17.0/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.7.2 h1:UuvKyZHl5p7u3ztEjtRtqtDxOjRKX5VUOgKFq6p6ETk= +github.com/bufbuild/protovalidate-go v0.7.2/go.mod h1:PHV5pFuWlRzdDW02/cmVyNzdiQ+RNNwo7idGxdzS7o4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/envoyproxy/protoc-gen-validate v1.0.2 h1:QkIBuU5k+x7/QXPvPPnWXWlCdaBFApVqftFV6k087DA= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/google/cel-go v0.17.4 h1:9556LOjSyIZlgnT0oaCYGq2uk9BM6fzuTXhzYHskonk= -github.com/google/cel-go v0.17.4/go.mod h1:HXZKzB0LXqer5lHHgfWAnlYwJaQBDKMjxjulNQzhwhY= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/envoyproxy/protoc-gen-validate v1.1.0 h1:tntQDh69XqOCOZsDz0lVJQez/2L6Uu2PdjCQwWCJ3bM= +github.com/envoyproxy/protoc-gen-validate v1.1.0/go.mod h1:sXRDRVmzEbkM7CVcM06s9shE/m23dg3wzjl0UWqJ2q4= +github.com/google/cel-go v0.21.0 h1:cl6uW/gxN+Hy50tNYvI691+sXxioCnstFzLp2WO4GCI= +github.com/google/cel-go v0.21.0/go.mod h1:rHUlWCcBKgyEk+eV03RPdZUekPp6YcJwV0FxuUksYxc= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stoewer/go-strcase v1.3.0 h1:g0eASXYtp+yvN9fK8sH94oCIk0fau9uV1/ZdJ0AVEzs= @@ -29,22 +29,23 @@ github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpE github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc= -golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w= -golang.org/x/text v0.10.0 h1:UpjohKhiEgNc0CSauXmwYftY1+LlaC75SJwh0SgCX58= -golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc h1:kVKPf/IiYSBWEWtkIn6wZXwWGCnLKcC8oWfZvXjsGnM= -google.golang.org/genproto/googleapis/api v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:vHYtlOoi6TsQ3Uk2yxR7NI5z8uoV+3pZtR4jmHIkRig= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc h1:XSJ8Vk1SWuNr8S18z1NZSziL0CPIXLCCMDOEFtHBOFc= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230530153820-e85fd2cbaebc/go.mod h1:66JfowdXAEgad5O9NnYcsNPLCPZJD++2L9X0PCMODrA= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 h1:aAcj0Da7eBAtrTp03QXWvm88pSyOt+UgdZw2BFZ+lEw= +golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8/go.mod h1:CQ1k9gNrJ50XIzaKCRR2hssIjF07kZFEiieALBM/ARQ= +golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs= +golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= +golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= +golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda h1:b6F6WIV4xHHD0FA4oIyzU6mHWg2WI2X1RBehwa5QN38= +google.golang.org/genproto/googleapis/api v0.0.0-20240401170217-c3f982113cda/go.mod h1:AHcE/gZH76Bk/ROZhQphlRoWo5xKDEtz3eVEO1LfA8c= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda h1:LI5DOvAxUPMv/50agcLLoo+AdWc1irS9Rzz4vPuD1V4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240401170217-c3f982113cda/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= +google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= +google.golang.org/protobuf v1.35.1/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/gen/example/calculator/v1/calculator.pb.go b/internal/gen/example/calculator/v1/calculator.pb.go index cff84f7..9658047 100644 --- a/internal/gen/example/calculator/v1/calculator.pb.go +++ b/internal/gen/example/calculator/v1/calculator.pb.go @@ -14,7 +14,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.35.1 // protoc (unknown) // source: example/calculator/v1/calculator.proto @@ -45,11 +45,9 @@ type CumSumRequest struct { func (x *CumSumRequest) Reset() { *x = CumSumRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_example_calculator_v1_calculator_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_example_calculator_v1_calculator_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *CumSumRequest) String() string { @@ -60,7 +58,7 @@ func (*CumSumRequest) ProtoMessage() {} func (x *CumSumRequest) ProtoReflect() protoreflect.Message { mi := &file_example_calculator_v1_calculator_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) @@ -92,11 +90,9 @@ type CumSumResponse struct { func (x *CumSumResponse) Reset() { *x = CumSumResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_example_calculator_v1_calculator_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_example_calculator_v1_calculator_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *CumSumResponse) String() string { @@ -107,7 +103,7 @@ func (*CumSumResponse) ProtoMessage() {} func (x *CumSumResponse) ProtoReflect() protoreflect.Message { mi := &file_example_calculator_v1_calculator_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) @@ -181,7 +177,7 @@ func file_example_calculator_v1_calculator_proto_rawDescGZIP() []byte { } var file_example_calculator_v1_calculator_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_example_calculator_v1_calculator_proto_goTypes = []interface{}{ +var file_example_calculator_v1_calculator_proto_goTypes = []any{ (*CumSumRequest)(nil), // 0: example.calculator.v1.CumSumRequest (*CumSumResponse)(nil), // 1: example.calculator.v1.CumSumResponse } @@ -200,32 +196,6 @@ func file_example_calculator_v1_calculator_proto_init() { if File_example_calculator_v1_calculator_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_example_calculator_v1_calculator_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CumSumRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_example_calculator_v1_calculator_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CumSumResponse); 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{ diff --git a/internal/gen/example/calculator/v1/calculatorv1connect/calculator.connect.go b/internal/gen/example/calculator/v1/calculatorv1connect/calculator.connect.go index 77767fd..6a641f2 100644 --- a/internal/gen/example/calculator/v1/calculatorv1connect/calculator.connect.go +++ b/internal/gen/example/calculator/v1/calculatorv1connect/calculator.connect.go @@ -32,7 +32,7 @@ import ( // generated with a version of connect newer than the one compiled into your binary. You can fix the // problem by either regenerating this code with an older version of connect or updating the connect // version compiled into your binary. -const _ = connect.IsAtLeastVersion0_1_0 +const _ = connect.IsAtLeastVersion1_13_0 const ( // CalculatorServiceName is the fully-qualified name of the CalculatorService service. @@ -52,6 +52,12 @@ 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] @@ -70,7 +76,8 @@ func NewCalculatorServiceClient(httpClient connect.HTTPClient, baseURL string, o cumSum: connect.NewClient[v1.CumSumRequest, v1.CumSumResponse]( httpClient, baseURL+CalculatorServiceCumSumProcedure, - opts..., + connect.WithSchema(calculatorServiceCumSumMethodDescriptor), + connect.WithClientOptions(opts...), ), } } @@ -100,7 +107,8 @@ func NewCalculatorServiceHandler(svc CalculatorServiceHandler, opts ...connect.H calculatorServiceCumSumHandler := connect.NewBidiStreamHandler( CalculatorServiceCumSumProcedure, svc.CumSum, - opts..., + connect.WithSchema(calculatorServiceCumSumMethodDescriptor), + connect.WithHandlerOptions(opts...), ) return "/example.calculator.v1.CalculatorService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { diff --git a/internal/gen/example/user/v1/user.pb.go b/internal/gen/example/user/v1/user.pb.go index a00d9af..10bd584 100644 --- a/internal/gen/example/user/v1/user.pb.go +++ b/internal/gen/example/user/v1/user.pb.go @@ -14,7 +14,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.31.0 +// protoc-gen-go v1.35.1 // protoc (unknown) // source: example/user/v1/user.proto @@ -48,11 +48,9 @@ type User struct { func (x *User) Reset() { *x = User{} - if protoimpl.UnsafeEnabled { - mi := &file_example_user_v1_user_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_example_user_v1_user_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *User) String() string { @@ -63,7 +61,7 @@ func (*User) ProtoMessage() {} func (x *User) ProtoReflect() protoreflect.Message { mi := &file_example_user_v1_user_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) @@ -109,11 +107,9 @@ type CreateUserRequest struct { func (x *CreateUserRequest) Reset() { *x = CreateUserRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_example_user_v1_user_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_example_user_v1_user_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *CreateUserRequest) String() string { @@ -124,7 +120,7 @@ func (*CreateUserRequest) ProtoMessage() {} func (x *CreateUserRequest) ProtoReflect() protoreflect.Message { mi := &file_example_user_v1_user_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) @@ -156,11 +152,9 @@ type CreateUserResponse struct { func (x *CreateUserResponse) Reset() { *x = CreateUserResponse{} - if protoimpl.UnsafeEnabled { - mi := &file_example_user_v1_user_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } + mi := &file_example_user_v1_user_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) } func (x *CreateUserResponse) String() string { @@ -171,7 +165,7 @@ func (*CreateUserResponse) ProtoMessage() {} func (x *CreateUserResponse) ProtoReflect() protoreflect.Message { mi := &file_example_user_v1_user_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) @@ -262,7 +256,7 @@ func file_example_user_v1_user_proto_rawDescGZIP() []byte { } var file_example_user_v1_user_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_example_user_v1_user_proto_goTypes = []interface{}{ +var file_example_user_v1_user_proto_goTypes = []any{ (*User)(nil), // 0: example.user.v1.User (*CreateUserRequest)(nil), // 1: example.user.v1.CreateUserRequest (*CreateUserResponse)(nil), // 2: example.user.v1.CreateUserResponse @@ -287,44 +281,6 @@ func file_example_user_v1_user_proto_init() { if File_example_user_v1_user_proto != nil { return } - if !protoimpl.UnsafeEnabled { - file_example_user_v1_user_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*User); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_example_user_v1_user_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateUserRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_example_user_v1_user_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*CreateUserResponse); 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{ diff --git a/internal/gen/example/user/v1/userv1connect/user.connect.go b/internal/gen/example/user/v1/userv1connect/user.connect.go index d072cae..fc2ded4 100644 --- a/internal/gen/example/user/v1/userv1connect/user.connect.go +++ b/internal/gen/example/user/v1/userv1connect/user.connect.go @@ -32,7 +32,7 @@ import ( // generated with a version of connect newer than the one compiled into your binary. You can fix the // problem by either regenerating this code with an older version of connect or updating the connect // version compiled into your binary. -const _ = connect.IsAtLeastVersion0_1_0 +const _ = connect.IsAtLeastVersion1_13_0 const ( // UserServiceName is the fully-qualified name of the UserService service. @@ -51,6 +51,12 @@ 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) @@ -69,7 +75,8 @@ func NewUserServiceClient(httpClient connect.HTTPClient, baseURL string, opts .. createUser: connect.NewClient[v1.CreateUserRequest, v1.CreateUserResponse]( httpClient, baseURL+UserServiceCreateUserProcedure, - opts..., + connect.WithSchema(userServiceCreateUserMethodDescriptor), + connect.WithClientOptions(opts...), ), } } @@ -98,7 +105,8 @@ func NewUserServiceHandler(svc UserServiceHandler, opts ...connect.HandlerOption userServiceCreateUserHandler := connect.NewUnaryHandler( UserServiceCreateUserProcedure, svc.CreateUser, - opts..., + connect.WithSchema(userServiceCreateUserMethodDescriptor), + connect.WithHandlerOptions(opts...), ) return "/example.user.v1.UserService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { diff --git a/internal/proto/example/user/v1/user.proto b/internal/proto/example/user/v1/user.proto index c21e028..2e75215 100644 --- a/internal/proto/example/user/v1/user.proto +++ b/internal/proto/example/user/v1/user.proto @@ -25,8 +25,8 @@ message User { google.protobuf.Timestamp signup_date = 3; option (buf.validate.message).cel = { - id: "user.signup_date", - message: "signup date must be on or after birth date", + id: "user.signup_date" + message: "signup date must be on or after birth date" expression: "this.signup_date >= this.birth_date" }; } diff --git a/validate_test.go b/validate_test.go index e6bfcb9..8cd84b5 100644 --- a/validate_test.go +++ b/validate_test.go @@ -102,7 +102,7 @@ func TestInterceptorUnary(t *testing.T) { violations, ok := detail.(*validatepb.Violations) require.True(t, ok) require.Len(t, violations.Violations, 1) - require.Equal(t, test.wantPath, violations.Violations[0].FieldPath) + require.Equal(t, test.wantPath, violations.Violations[0].GetFieldPath()) } } else { require.NoError(t, err) @@ -188,7 +188,7 @@ func TestInterceptorStreamingHandler(t *testing.T) { violations, ok := detail.(*validatepb.Violations) require.True(t, ok) require.Len(t, violations.Violations, 1) - require.Equal(t, test.wantPath, violations.Violations[0].FieldPath) + require.Equal(t, test.wantPath, violations.Violations[0].GetFieldPath()) } } else { require.NoError(t, err) @@ -275,7 +275,7 @@ func TestInterceptorStreamingClient(t *testing.T) { violations, ok := detail.(*validatepb.Violations) require.True(t, ok) require.Len(t, violations.Violations, 1) - require.Equal(t, test.wantPath, violations.Violations[0].FieldPath) + require.Equal(t, test.wantPath, violations.Violations[0].GetFieldPath()) } } else { require.NoError(t, err)