From 0092d3a118f5839b1379fc35329f2fdcf7afcdad Mon Sep 17 00:00:00 2001 From: Matt Date: Fri, 27 Sep 2024 22:51:14 -0700 Subject: [PATCH] Upgrade to Go 1.22 toolchain (#1987) Upgrades to the Go 1.22 toolchain. Upgrades golangci-lint to 1.61.0 and disables some new linters. --------- Co-authored-by: Nicholas Wiersma --- .github/workflows/ci.yml | 4 +-- .github/workflows/goreleaser.yml | 2 +- .golangci.yml | 24 +++++++++-------- Dockerfile.test | 2 +- appveyor.yml | 2 +- cmd/proxy/Dockerfile | 2 +- docker-compose.yml | 6 ++--- go.mod | 2 +- go.sum | 11 ++++++++ pkg/storage/compliance/benchmarks.go | 39 ++++++++++++++++------------ scripts/build-image/Dockerfile | 2 +- 11 files changed, 56 insertions(+), 40 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f27b80e8..47f3e4c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,7 @@ jobs: lint: runs-on: ubuntu-latest env: - GOLANGCI_LINT_VERSION: v1.51.2 + GOLANGCI_LINT_VERSION: v1.61.0 steps: - uses: actions/checkout@v4 @@ -24,8 +24,6 @@ jobs: uses: golangci/golangci-lint-action@v6 with: version: ${{ env.GOLANGCI_LINT_VERSION }} - skip-pkg-cache: true - skip-build-cache: true build: env: diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml index 6ff252a8..97c98fb6 100644 --- a/.github/workflows/goreleaser.yml +++ b/.github/workflows/goreleaser.yml @@ -14,7 +14,7 @@ jobs: - name: setup-go uses: actions/setup-go@v5 with: - go-version: "1.20" + go-version-file: 'go.mod' - name: capture current date id: date run: echo "::set-output name=date::$(date -u '+%Y-%m-%d-%H:%M:%S-%Z')" diff --git a/.golangci.yml b/.golangci.yml index 3111c62b..28e1c710 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -16,26 +16,27 @@ linters-settings: linters: enable-all: true disable: - - interfacer # deprecated - - scopelint # deprecated - - maligned # deprecated - - golint # deprecated - - structcheck # deprecated - - deadcode # deprecated - - varcheck # deprecated - - nosnakecase # deprecated - - ifshort # deprecated + - perfsprint # new + - testifylint # new + - spancheck # new + - rowserrcheck # new + - mnd # new + - intrange # new + - depguard # new + - revive # new + - errcheck # new - errchkjson - exhaustive - - exhaustivestruct - exhaustruct + - execinquery # deprecated + - exportloopref # deprecated - forcetypeassert - funlen - gochecknoglobals - gochecknoinits - goconst - godox - - goerr113 + - err113 - gomnd - ireturn - lll @@ -60,6 +61,7 @@ issues: - "G204: Subprocess launched with variable" - "G402: TLS MinVersion too low." - "const `op` is unused" + - "G115: integer overflow conversion int -> int32" exclude-rules: - path: cmd/proxy/main.go text: "G108: Profiling endpoint is automatically exposed on /debug/pprof" diff --git a/Dockerfile.test b/Dockerfile.test index fc205e3f..8141c725 100644 --- a/Dockerfile.test +++ b/Dockerfile.test @@ -1,4 +1,4 @@ -ARG GOLANG_VERSION=1.20 +ARG GOLANG_VERSION=1.22 FROM golang:$GOLANG_VERSION RUN echo $GOLANG_VERSION diff --git a/appveyor.yml b/appveyor.yml index 6ae53ddf..f58325e2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,7 +10,7 @@ environment: GOPROXY: https://proxy.golang.org SKIP_UNTIL_113: true -stack: go 1.20 +stack: go 1.22 test_script: - go version diff --git a/cmd/proxy/Dockerfile b/cmd/proxy/Dockerfile index 7a33221c..2c52b068 100644 --- a/cmd/proxy/Dockerfile +++ b/cmd/proxy/Dockerfile @@ -5,7 +5,7 @@ # You can override the Go version used to build the image. # See project Makefile if using make. # See docker --build-arg if building directly. -ARG GOLANG_VERSION=1.20 +ARG GOLANG_VERSION=1.22 ARG ALPINE_VERSION=3.17 FROM golang:${GOLANG_VERSION}-alpine AS builder diff --git a/docker-compose.yml b/docker-compose.yml index b86946af..de7afed8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: context: . dockerfile: cmd/proxy/Dockerfile args: - GOLANG_VERSION: "1.20" + GOLANG_VERSION: "1.22" environment: - ATHENS_MONGO_STORAGE_URL=mongodb://mongo:27017 - TIMEOUT=20 # in case the mongo dependency takes longer to start up @@ -20,7 +20,7 @@ services: context: . dockerfile: Dockerfile.test args: - GOLANG_VERSION: "1.20" + GOLANG_VERSION: "1.22" command: ["./scripts/test_unit.sh"] environment: - GO_ENV=test @@ -36,7 +36,7 @@ services: context: . dockerfile: Dockerfile.test args: - GOLANG_VERSION: "1.20" + GOLANG_VERSION: "1.22" command: ["./scripts/test_e2e.sh"] azurite: image: arafato/azurite:2.6.5 diff --git a/go.mod b/go.mod index c819e065..00a45ced 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/gomods/athens -go 1.20 +go 1.22 require ( cloud.google.com/go/storage v1.36.0 diff --git a/go.sum b/go.sum index a5384474..51e1cbbb 100644 --- a/go.sum +++ b/go.sum @@ -167,7 +167,9 @@ github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGX github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/xds/go v0.0.0-20231109132714-523115ebc101 h1:7To3pQ+pZo0i3dsWEbinPNFs5gPSBOsJtx3wTT94VBY= +github.com/cncf/xds/go v0.0.0-20231109132714-523115ebc101/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cockroachdb/datadriven v1.0.2 h1:H9MtNqVoVhvd9nCBwOyDjUEdZCREqbIdCJD93PBm/jA= +github.com/cockroachdb/datadriven v1.0.2/go.mod h1:a9RdTaap04u637JoCzcUoIcDmvwSUtcUFtT/C3kJlTU= github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4= github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec= github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= @@ -188,6 +190,7 @@ github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5y github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v1.0.2 h1:QkIBuU5k+x7/QXPvPPnWXWlCdaBFApVqftFV6k087DA= +github.com/envoyproxy/protoc-gen-validate v1.0.2/go.mod h1:GpiZQP3dDbg4JouG/NNS7QWXpgx6x8QiMKdmN72jogE= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= @@ -209,6 +212,7 @@ github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ4 github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= @@ -318,6 +322,7 @@ github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXi github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.3.2 h1:IqNFLAmvJOgVlpdEBiQbDc2EwKW77amAycfTuWKdfvw= +github.com/google/martian/v3 v3.3.2/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= @@ -408,9 +413,11 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxv github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= @@ -609,6 +616,7 @@ go.opentelemetry.io/proto/otlp v1.1.0/go.mod h1:GpBHCBWiqvVLDqmHZsoMM3C5ySeKTC7e go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= @@ -878,11 +886,13 @@ golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= +golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= @@ -995,6 +1005,7 @@ gopkg.in/DataDog/dd-trace-go.v1 v1.10.0/go.mod h1:DVp8HmDh8PuTu2Z0fVVlBsyWaC++fz gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/ini.v1 v1.42.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= diff --git a/pkg/storage/compliance/benchmarks.go b/pkg/storage/compliance/benchmarks.go index b3325dd5..390dada7 100644 --- a/pkg/storage/compliance/benchmarks.go +++ b/pkg/storage/compliance/benchmarks.go @@ -13,16 +13,18 @@ import ( // RunBenchmarks takes a backend and runs benchmarks against // saving and loading modules. -func RunBenchmarks(b *testing.B, s storage.Backend, clear func() error) { - benchList(b, s, clear) - benchSave(b, s, clear) - benchDelete(b, s, clear) - benchExists(b, s, clear) +func RunBenchmarks(b *testing.B, s storage.Backend, reset func() error) { + b.Helper() + benchList(b, s, reset) + benchSave(b, s, reset) + benchDelete(b, s, reset) + benchExists(b, s, reset) } -func benchList(b *testing.B, s storage.Backend, clear func() error) { - require.NoError(b, clear()) - defer require.NoError(b, clear()) +func benchList(b *testing.B, s storage.Backend, reset func() error) { + b.Helper() + require.NoError(b, reset()) + defer require.NoError(b, reset()) module, version := "benchListModule", "1.0.1" mock := getMockModule() err := s.Save( @@ -43,9 +45,10 @@ func benchList(b *testing.B, s storage.Backend, clear func() error) { }) } -func benchSave(b *testing.B, s storage.Backend, clear func() error) { - require.NoError(b, clear()) - defer require.NoError(b, clear()) +func benchSave(b *testing.B, s storage.Backend, reset func() error) { + b.Helper() + require.NoError(b, reset()) + defer require.NoError(b, reset()) module, version := "benchSaveModule", "1.0.1" mock := getMockModule() @@ -70,9 +73,10 @@ func benchSave(b *testing.B, s storage.Backend, clear func() error) { }) } -func benchDelete(b *testing.B, s storage.Backend, clear func() error) { - require.NoError(b, clear()) - defer require.NoError(b, clear()) +func benchDelete(b *testing.B, s storage.Backend, reset func() error) { + b.Helper() + require.NoError(b, reset()) + defer require.NoError(b, reset()) module, version := "benchDeleteModule", "1.0.1" mock := getMockModule() @@ -91,9 +95,10 @@ func benchDelete(b *testing.B, s storage.Backend, clear func() error) { }) } -func benchExists(b *testing.B, s storage.Backend, clear func() error) { - require.NoError(b, clear()) - defer require.NoError(b, clear()) +func benchExists(b *testing.B, s storage.Backend, reset func() error) { + b.Helper() + require.NoError(b, reset()) + defer require.NoError(b, reset()) module, version := "benchExistsModule", "1.0.1" mock := getMockModule() diff --git a/scripts/build-image/Dockerfile b/scripts/build-image/Dockerfile index f462a39d..1c501e4e 100644 --- a/scripts/build-image/Dockerfile +++ b/scripts/build-image/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.20-bullseye +FROM golang:1.22-bullseye WORKDIR /tmp