-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker image golangci/golangci-lint:v1.55.2 errors when project go.mod requires go v1.21.4 #4239
Comments
Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors. |
Hello, the problem is not with golangci-lint itself but with the Docker image or your CI: the image contains go1.21.3. $ docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.55.2 go version
go version go1.21.3 linux/amd64 $ docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.55.2 go build
go: go.mod requires go >= 1.21.4 (running go 1.21.3; GOTOOLCHAIN=local) $ docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.55.2 golangci-lint run
level=error msg="Running error: context loading failed: failed to load packages: failed to load with go/packages: err: exit status 1: stderr: go: go.mod requires go >= 1.21.4 (running go 1.21.3; GOTOOLCHAIN=local)\n" The Go version inside the Docker image is defined during the build of the image, golangci-lint has the same behavior as Go, so this behavior is expected. |
Is updating the image something I have to do to get support for go version 1.21.4? |
$ docker run --rm -it -v $(pwd):/app -w /app golangci/golangci-lint:v1.55.2 sh
# go version
go version go1.21.3 linux/amd64
# go build
go: go.mod requires go >= 1.21.4 (running go 1.21.3; GOTOOLCHAIN=local)
# golangci-lint run
ERRO Running error: context loading failed: failed to load packages: failed to load with go/packages: err: exit status 1: stderr: go: go.mod requires go >= 1.21.4 (running go 1.21.3; GOTOOLCHAIN=local)
# curl -L https://go.dev/dl/go1.21.5.linux-amd64.tar.gz --output go1.21.5.linux-amd64.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 75 100 75 0 0 383 0 --:--:-- --:--:-- --:--:-- 384
100 63.5M 100 63.5M 0 0 57.4M 0 0:00:01 0:00:01 --:--:-- 74.4M
# rm -rf /usr/local/go && tar -C /usr/local -xzf go1.21.5.linux-amd64.tar.gz
# go version
go version go1.21.5 linux/amd64
# go build
# golangci-lint run
# golangci-lint is compiled with go1.21 but it requires running some Go commands, so the installed version of Go has an impact. The strong Go version requirement is something new, it comes with go1.21. |
Okay. Thanks for the explanation and work around! |
A possible solution seems to be setting Go Toolchain, for example: $ golangci-lint run -v
...
ERRO Running error: context loading failed: failed to load packages: failed to load with go/packages: err: exit status 1: stderr: go: go.mod requires go >= 1.22.1 (running go 1.22.0; GOTOOLCHAIN=local)
$ GOTOOLCHAIN=go1.22.1 golangci-lint run -v
...
INFO Execution took 776.326069ms The tool chain can also be set in $ GOTOOLCHAIN=$(awk '/^go / {gsub(/ /, "", $0); print}' go.mod) golangci-lint run |
Welcome
Description of the problem
I've seen when using docker image
golangci/golangci-lint:v1.55.2
(like in CI/CD or standalone in docker) on a Go project that has ago.mod
file require go version1.21.4
an error getting thrown:level=error msg="Running error: context loading failed: failed to load packages: failed to load with go/packages: err: exit status 1: stderr: go: go.mod requires go >= 1.21.4 (running go 1.21.3; GOTOOLCHAIN=local)\n"
Version of golangci-lint
Configuration
No custom configuration file is used.
Go environment
Verbose output of running
A minimal reproducible example or link to a public repository
From repo scacner/go-hello-world
Validation
The text was updated successfully, but these errors were encountered: