golangci / golangci-lint

Fast linters runner for Go
https://golangci-lint.run
GNU General Public License v3.0
15.66k stars 1.39k forks source link

the Go language version (go1.22) used to build golangci-lint is lower than the targeted Go version (1.23.1) #5032

Closed rach-id closed 1 month ago

rach-id commented 1 month ago

Welcome

Description of the problem

I am trying to use the linter locally on a go 1.23.1 project, and it still doesn't work (even tho we have this issue: https://github.com/golangci/golangci-lint/issues/4837):

$ go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.61.0 run

Error: can't load config: the Go language version (go1.22) used to build golangci-lint is lower than the targeted Go version (1.23.1)
Failed executing command with error: can't load config: the Go language version (go1.22) used to build golangci-lint is lower than the targeted Go version (1.23.1)
exit status 3

Version of golangci-lint

```console $ golangci-lint --version golangci-lint has version v1.61.0 built with go1.22.3 from (unknown, modified: ?, mod sum: "h1:VvbOLaRVWmyxCnUIMTbf1kDsaJbTzH20FAMXTAlQGu8=") on (unknown) ```

Configuration

```console # paste configuration file or CLI flags here ```

Go environment

```console $ go version && go env go version go1.23.1 darwin/arm64 GO111MODULE='on' GOARCH='arm64' GOBIN='' GOCACHE='/Users/ee/Library/Caches/go-build' GOENV='/Users/ee/Library/Application Support/go/env' GOEXE='' GOEXPERIMENT='' GOFLAGS='' GOHOSTARCH='arm64' GOHOSTOS='darwin' GOINSECURE='' GOMODCACHE='/Users/ee/go2/pkg/mod' GONOPROXY='' GONOSUMDB='' GOOS='darwin' GOPATH='/Users/ee/go2' GOPRIVATE='' GOPROXY='https://proxy.golang.org,direct' GOROOT='/Users/midnight/go2/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.1.darwin-arm64' GOSUMDB='sum.golang.org' GOTMPDIR='' GOTOOLCHAIN='auto' GOTOOLDIR='/Users/midnight/go2/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.1.darwin-arm64/pkg/tool/darwin_arm64' GOVCS='' GOVERSION='go1.23.1' GODEBUG='' GOTELEMETRY='local' GOTELEMETRYDIR='/Users/ee/Library/Application Support/go/telemetry' GCCGO='gccgo' GOARM64='v8.0' AR='ar' CC='clang' CXX='clang++' CGO_ENABLED='1' GOMOD='/Users/midnight/project/go.mod' GOWORK='' CGO_CFLAGS='-O2 -g' CGO_CPPFLAGS='' CGO_CXXFLAGS='-O2 -g' CGO_FFLAGS='-O2 -g' CGO_LDFLAGS='-O2 -g' PKG_CONFIG='pkg-config' GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/x4/70_kh46s0xqglq6c_wmyq7c00000gn/T/go-build3142003902=/tmp/go-build -gno-record-gcc-switches -fno-common' ```

Verbose output of running

```console $ golangci-lint cache clean $ golangci-lint run -v INFO golangci-lint has version v1.61.0 built with go1.22.3 from (unknown, modified: ?, mod sum: "h1:VvbOLaRVWmyxCnUIMTbf1kDsaJbTzH20FAMXTAlQGu8=") on (unknown) Error: can't load config: the Go language version (go1.22) used to build golangci-lint is lower than the targeted Go version (1.23.1) Failed executing command with error: can't load config: the Go language version (go1.22) used to build golangci-lint is lower than the targeted Go version (1.23.1) ```

A minimal reproducible example or link to a public repository

Run `make lint` on this: https://github.com/celestiaorg/celestia-core

Validation

Supporter

boring-cyborg[bot] commented 1 month ago

Hey, thank you for opening your first Issue ! 🙂 If you would like to contribute we have a guide for contributors.

ldez commented 1 month ago

Hello,

golangci-lint has version v1.61.0 built with go1.22.3 from (unknown, modified: ?, mod sum: "h1:VvbOLaRVWmyxCnUIMTbf1kDsaJbTzH20FAMXTAlQGu8=") on (unknown) ... Error: can't load config: the Go language version (go1.22) used to build golangci-lint is lower than the targeted Go version (1.23.1)

You are using a custom version of golangci-lint build with go1.22 but you are trying to analyze go1.23 code, this cannot work.

You should use a version of golangci-lint compiled with go1.23 to analyze go1.23 code.

rach-id commented 1 month ago

But this is the latest version. Or you mean I should rebuild it from source using go 1.23.1?

ldez commented 1 month ago

To analyze go1.23 code, golangci-lint needs to be compiled by go1.23. This is not related to the golangci-lint version.

The patch version (go1.23.1) of Go doesn't impact this, because there is a difference between Go language version (Go family version) and Go version.

https://go.dev/doc/toolchain#version

Your problem is that you are compiling with go1.22.

INFO golangci-lint has version v1.61.0 built with go1.22.3 from (unknown, modified: ?, mod sum: "h1:VvbOLaRVWmyxCnUIMTbf1kDsaJbTzH20FAMXTAlQGu8=") on (unknown)

The commands go run and go install are compiling golangci-lint, and you are compiling with go1.22 (go1.22.3) and not go1.23.

I recommend using the official golangci-lint binaries:

rach-id commented 1 month ago

aaaah, got you. Thanks a lot for your help 🙏 :pray:

ldez commented 1 month ago

I hope you enjoyed our work, please consider donating or asking your company to do so. This will be appreciated, thank you :heart:

Open Collective backers and sponsors GitHub Sponsors