diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index dc8c2f1ae2b6..64ad95822737 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -30,5 +30,5 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@639cd343e1d3b897ff35927a75193d57cfcba299 # tag=v3.6.0 with: - version: v1.53.3 + version: v1.55.2 working-directory: ${{matrix.working-directory}} diff --git a/.golangci.yml b/.golangci.yml index 6af1f0ddce21..3672e3744152 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,6 @@ run: timeout: 10m - go: "1.20" + go: "1.21" build-tags: - tools - e2e @@ -211,7 +211,8 @@ linters-settings: # - name: bool-literal-in-expr - name: constant-logical-expr - + goconst: + ignore-tests: true issues: max-same-issues: 0 max-issues-per-linter: 0 @@ -323,3 +324,9 @@ issues: - gocritic text: "deferInLoop: Possible resource leak, 'defer' is called in the 'for' loop" path: _test\.go + # Note: We only found issues with memory aliasing after backporting Go 1.21 and a new golangci-lint version. + # Let's not waste time fixing memory aliasing in unit tests on this branch. + - linters: + - gosec + text: "G601: Implicit memory aliasing in for loop" + path: _test\.go diff --git a/Makefile b/Makefile index e77065b74a4a..92c0390ed554 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ SHELL:=/usr/bin/env bash # # Go. # -GO_VERSION ?= 1.20.12 +GO_VERSION ?= 1.21.5 GO_CONTAINER_IMAGE ?= docker.io/library/golang:$(GO_VERSION) # Use GOPROXY environment variable if set diff --git a/Tiltfile b/Tiltfile index 8426af5b37f6..c33221860be5 100644 --- a/Tiltfile +++ b/Tiltfile @@ -184,9 +184,9 @@ def load_provider_tiltfiles(): tilt_helper_dockerfile_header = """ # Tilt image -FROM golang:1.20.12 as tilt-helper +FROM golang:1.21.5 as tilt-helper # Install delve. Note this should be kept in step with the Go release minor version. -RUN go install github.com/go-delve/delve/cmd/dlv@v1.20 +RUN go install github.com/go-delve/delve/cmd/dlv@v1.21 # Support live reloading with Tilt RUN wget --output-document /restart.sh --quiet https://raw.githubusercontent.com/tilt-dev/rerun-process-wrapper/master/restart.sh && \ wget --output-document /start.sh --quiet https://raw.githubusercontent.com/tilt-dev/rerun-process-wrapper/master/start.sh && \ @@ -195,7 +195,7 @@ RUN wget --output-document /restart.sh --quiet https://raw.githubusercontent.com """ tilt_dockerfile_header = """ -FROM golang:1.20.12 as tilt +FROM golang:1.21.5 as tilt WORKDIR / COPY --from=tilt-helper /process.txt . COPY --from=tilt-helper /start.sh . diff --git a/cmd/clusterctl/client/move.go b/cmd/clusterctl/client/move.go index 38617143237c..e2bf322501b8 100644 --- a/cmd/clusterctl/client/move.go +++ b/cmd/clusterctl/client/move.go @@ -69,9 +69,9 @@ func (c *clusterctlClient) Move(options MoveOptions) error { return c.toDirectory(options) } else if options.FromDirectory != "" { return c.fromDirectory(options) - } else { - return c.move(options) } + + return c.move(options) } func (c *clusterctlClient) move(options MoveOptions) error { diff --git a/exp/runtime/hooks/api/v1alpha1/discovery_types.go b/exp/runtime/hooks/api/v1alpha1/discovery_types.go index 840dd2986061..276833ec15d0 100644 --- a/exp/runtime/hooks/api/v1alpha1/discovery_types.go +++ b/exp/runtime/hooks/api/v1alpha1/discovery_types.go @@ -100,7 +100,7 @@ func init() { "Runtime Extension implementers must use this hook to inform the Cluster API runtime about all the handlers " + "that are defined in an external component implementing Runtime Extensions.\n" + "\n" + - "Notes:\n" + + "Notes:\n" + //nolint:goconst "- When using Runtime SDK utils, a handler for this hook is automatically generated", Singleton: true, }) diff --git a/exp/runtime/hooks/api/v1alpha1/lifecyclehooks_types.go b/exp/runtime/hooks/api/v1alpha1/lifecyclehooks_types.go index 3293b10877b0..fa91a2e6635a 100644 --- a/exp/runtime/hooks/api/v1alpha1/lifecyclehooks_types.go +++ b/exp/runtime/hooks/api/v1alpha1/lifecyclehooks_types.go @@ -204,7 +204,7 @@ func init() { "all the objects which are part of a Cluster's topology are going to be created.\n" + "\n" + "Notes:\n" + - "- This hook will be called only for Clusters with a managed topology\n" + + "- This hook will be called only for Clusters with a managed topology\n" + //nolint:goconst "- The call's request contains the Cluster object\n" + "- This is a blocking hook; Runtime Extension implementers can use this hook to execute\n" + "tasks before the objects which are part of a Cluster's topology are created", diff --git a/hack/ensure-go.sh b/hack/ensure-go.sh index d19b6cd596c5..96f0567f86c5 100755 --- a/hack/ensure-go.sh +++ b/hack/ensure-go.sh @@ -38,7 +38,7 @@ EOF local go_version IFS=" " read -ra go_version <<< "$(go version)" local minimum_go_version - minimum_go_version=go1.20 + minimum_go_version=go1.21 if [[ "${minimum_go_version}" != $(echo -e "${minimum_go_version}\n${go_version[2]}" | sort -s -t. -k 1,1 -k 2,2n -k 3,3n | head -n1) && "${go_version[2]}" != "devel" ]]; then cat <") Expect(machineSetFD).To(Equal(machineDeploymentFD), "MachineSet %s is in the %q failure domain, expecting %q", machineSet.Name, machineSetFD, machineDeploymentFD) diff --git a/test/infrastructure/inmemory/internal/controllers/inmemorymachine_controller_test.go b/test/infrastructure/inmemory/internal/controllers/inmemorymachine_controller_test.go index eea1c6bc7fc0..70643ba4d280 100644 --- a/test/infrastructure/inmemory/internal/controllers/inmemorymachine_controller_test.go +++ b/test/infrastructure/inmemory/internal/controllers/inmemorymachine_controller_test.go @@ -313,7 +313,7 @@ func TestReconcileNormalEtcd(t *testing.T) { manager := cmanager.New(scheme) - host := "127.0.0.1" //nolint:goconst + host := "127.0.0.1" wcmux, err := server.NewWorkloadClustersMux(manager, host, server.CustomPorts{ // NOTE: make sure to use ports different than other tests, so we can run tests in parallel MinPort: server.DefaultMinPort + 1000, diff --git a/test/infrastructure/inmemory/internal/server/mux_test.go b/test/infrastructure/inmemory/internal/server/mux_test.go index 7072df7a9518..914ad30ff055 100644 --- a/test/infrastructure/inmemory/internal/server/mux_test.go +++ b/test/infrastructure/inmemory/internal/server/mux_test.go @@ -67,7 +67,7 @@ func TestMux(t *testing.T) { manager := cmanager.New(scheme) wcl := "workload-cluster" - host := "127.0.0.1" //nolint:goconst + host := "127.0.0.1" wcmux, err := NewWorkloadClustersMux(manager, host, CustomPorts{ // NOTE: make sure to use ports different than other tests, so we can run tests in parallel MinPort: DefaultMinPort, diff --git a/util/version/version.go b/util/version/version.go index 277ed61050ec..7ddfa4d27a42 100644 --- a/util/version/version.go +++ b/util/version/version.go @@ -115,9 +115,9 @@ func (v buildIdentifiers) compare(o buildIdentifiers) int { return 0 } else if i == len(v) && i < len(o) { return -1 - } else { - return 1 } + + return 1 } type buildIdentifier struct {