From 64278935504606ae2d5ff984edeaaf68cf773a71 Mon Sep 17 00:00:00 2001 From: Dmitriy Matrenichev Date: Wed, 3 Aug 2022 18:36:36 +0300 Subject: [PATCH] chore: bump Go and fix lint issues - Bump required Go version from 1.18 to 1.19 - Remove Pointer type (we didn't use anyway, and Go 1.19 have it). - Fix linter complains Signed-off-by: Dmitriy Matrenichev --- .dockerignore | 3 +-- Dockerfile | 6 +++--- Makefile | 10 +++++----- go.mod | 2 +- person_test.go | 2 ++ pointer.go | 24 ------------------------ protobuf_test.go | 34 +++++++++++++++++----------------- type_cache.go | 1 + 8 files changed, 30 insertions(+), 52 deletions(-) delete mode 100644 pointer.go diff --git a/.dockerignore b/.dockerignore index c66fae5..415c988 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,6 +1,6 @@ # THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. # -# Generated on 2022-08-02T12:15:47Z by kres latest. +# Generated on 2022-08-03T15:33:56Z by kres latest. ** !messages @@ -15,7 +15,6 @@ !marshal.go !marshal_test.go !person_test.go -!pointer.go !predefined_types.go !protobuf_test.go !type_cache.go diff --git a/Dockerfile b/Dockerfile index e5abaa0..0d13454 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ # THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. # -# Generated on 2022-08-02T12:15:47Z by kres latest. +# Generated on 2022-08-03T15:33:56Z by kres latest. ARG TOOLCHAIN @@ -20,7 +20,8 @@ ENV GO111MODULE on ENV CGO_ENABLED 0 ENV GOPATH /go ARG GOLANGCILINT_VERSION -RUN curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/${GOLANGCILINT_VERSION}/install.sh | bash -s -- -b /bin ${GOLANGCILINT_VERSION} +RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCILINT_VERSION} \ + && mv /go/bin/golangci-lint /bin/golangci-lint ARG GOFUMPT_VERSION RUN go install mvdan.cc/gofumpt@${GOFUMPT_VERSION} \ && mv /go/bin/gofumpt /bin/gofumpt @@ -59,7 +60,6 @@ COPY ./map_test.go ./map_test.go COPY ./marshal.go ./marshal.go COPY ./marshal_test.go ./marshal_test.go COPY ./person_test.go ./person_test.go -COPY ./pointer.go ./pointer.go COPY ./predefined_types.go ./predefined_types.go COPY ./protobuf_test.go ./protobuf_test.go COPY ./type_cache.go ./type_cache.go diff --git a/Makefile b/Makefile index 416864e..4c2486a 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT. # -# Generated on 2022-08-02T12:15:47Z by kres latest. +# Generated on 2022-08-03T15:29:15Z by kres latest. # common variables @@ -13,11 +13,11 @@ USERNAME ?= siderolabs REGISTRY_AND_USERNAME ?= $(REGISTRY)/$(USERNAME) GOLANGCILINT_VERSION ?= v1.47.3 GOFUMPT_VERSION ?= v0.3.1 -GO_VERSION ?= 1.18 +GO_VERSION ?= 1.19 GOIMPORTS_VERSION ?= v0.1.11 -PROTOBUF_GO_VERSION ?= 1.28.0 +PROTOBUF_GO_VERSION ?= 1.28.1 GRPC_GO_VERSION ?= 1.2.0 -GRPC_GATEWAY_VERSION ?= 2.10.0 +GRPC_GATEWAY_VERSION ?= 2.11.1 VTPROTOBUF_VERSION ?= 0.3.0 DEEPCOPY_VERSION ?= v0.5.5 TESTPKGS ?= ./... @@ -49,7 +49,7 @@ COMMON_ARGS += --build-arg=GRPC_GATEWAY_VERSION=$(GRPC_GATEWAY_VERSION) COMMON_ARGS += --build-arg=VTPROTOBUF_VERSION=$(VTPROTOBUF_VERSION) COMMON_ARGS += --build-arg=DEEPCOPY_VERSION=$(DEEPCOPY_VERSION) COMMON_ARGS += --build-arg=TESTPKGS=$(TESTPKGS) -TOOLCHAIN ?= docker.io/golang:1.18-alpine +TOOLCHAIN ?= docker.io/golang:1.19-alpine # help menu diff --git a/go.mod b/go.mod index 93684d8..2fa9b58 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/siderolabs/protoenc -go 1.18 +go 1.19 require ( github.com/brianvoe/gofakeit/v6 v6.17.0 diff --git a/person_test.go b/person_test.go index f72bf7a..9844051 100644 --- a/person_test.go +++ b/person_test.go @@ -13,6 +13,7 @@ import ( ) // Go-based protobuf definition for the example Person message format +// //nolint:govet type Person struct { Name string `protobuf:"1"` @@ -37,6 +38,7 @@ type PhoneNumber struct { // This example defines, encodes, and decodes a Person message format // equivalent to the example used in the Protocol Buffers overview. +// //nolint:nosnakecase func Example_protobuf() { // Create a Person record diff --git a/pointer.go b/pointer.go deleted file mode 100644 index 2e15606..0000000 --- a/pointer.go +++ /dev/null @@ -1,24 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -package protoenc - -import ( - "sync/atomic" - "unsafe" -) - -// A Pointer is an atomic pointer of type *T. The zero value is a nil *T. -type Pointer[T any] struct { - // TODO: remove this once Go 1.19 lands. - v unsafe.Pointer -} - -// Load atomically loads and returns the value stored in x. -func (x *Pointer[T]) Load() *T { return (*T)(atomic.LoadPointer(&x.v)) } - -// CompareAndSwap executes the compare-and-swap operation for x. -func (x *Pointer[T]) CompareAndSwap(old, newVal *T) (swapped bool) { - return atomic.CompareAndSwapPointer(&x.v, unsafe.Pointer(old), unsafe.Pointer(newVal)) -} diff --git a/protobuf_test.go b/protobuf_test.go index 73699c9..7254805 100644 --- a/protobuf_test.go +++ b/protobuf_test.go @@ -222,24 +222,24 @@ func TestTimeTypesEncodeDecode(t *testing.T) { assert.Equal(t, in.Duration, out.Duration) } -/* encoding of testMsg is equivalent to the encoding to the following in - a .proto file: - message cipherText { - int32 a = 1; - int32 b = 2; - } - - message MapFieldEntry { - uint32 key = 1; - cipherText value = 2; - } - - message testMsg { - repeated MapFieldEntry map_field = 1; - } - for details see: -https://developers.google.com/protocol-buffers/docs/proto#backwards-compatibility */ type wrongTestMsg struct { + /* encoding of testMsg is equivalent to the encoding to the following in + a .proto file: + message cipherText { + int32 a = 1; + int32 b = 2; + } + + message MapFieldEntry { + uint32 key = 1; + cipherText value = 2; + } + + message testMsg { + repeated MapFieldEntry map_field = 1; + } + for details see: + https://developers.google.com/protocol-buffers/docs/proto#backwards-compatibility */ M map[uint32][]cipherText } diff --git a/type_cache.go b/type_cache.go index 72b32bd..774f96c 100644 --- a/type_cache.go +++ b/type_cache.go @@ -35,6 +35,7 @@ func StructFields(typ reflect.Type) ([]FieldData, error) { } // FieldData represents a field of a struct with proto number and field index. +// //nolint:govet type FieldData struct { Num protowire.Number