Skip to content

Disable automatic toolchain switching in golang #3300

Description

@AleksaC

search you tried in the issue tracker

toolchain

describe your issue

In version 1.21 go introduced automatic toolchain switching, which basically means downloading the go version specified in the go.mod file if it's newer than the one being used.

This is the cause of #3149. In that case the command failed only because the helm docs set go 1.22 in go.mod. Had they set 1.22.0 that version would have been downloaded and the build would work.

This may not be bad if language_version isn't specified, because autoupdate would only break in case the full version isn't specified like the above. However, this breaks the language_version if it is specified. Here's an example:

default_language_version:
  golang: "1.21.0"

repos:
- repo: https://github.com/golangci/golangci-lint
  rev: v1.61.0  # uses go 1.22.1
  hooks:
    - id: golangci-lint-config-verify
$ ~/.cache/pre-commit/repoka9x_fj6/golangenv-1.21.0/bin/golangci-lint version
golangci-lint has version (devel) built with go1.22.1 from (a1d6c560de1a193a0c68ffed68cd5928ef39e884, modified: true, mod sum: "") on 2024-09-09T14:33:19Z

pre-commit --version

pre-commit 3.8.0

.pre-commit-config.yaml

default_language_version:
  golang: "1.21.0"

repos:
- repo: https://github.com/golangci/golangci-lint
  rev: v1.61.0  # uses go 1.22.1
  hooks:
    - id: golangci-lint-config-verify

~/.cache/pre-commit/pre-commit.log (if present)

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions