{"record":{"id":"bfad3da346c3f4e4","repo":"golangci/golangci-lint","slug":"the-go-language-version-s-used-to-build-golangc","errorCode":null,"errorMessage":"the Go language version (%s) used to build golangci-lint is lower than the targeted Go version (%s)","messagePattern":"the Go language version \\((.+?)\\) used to build golangci-lint is lower than the targeted Go version \\((.+?)\\)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/goutil/version.go","lineNumber":32,"sourceCode":"\trv, err := CleanRuntimeVersion()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"clean runtime version: %w\", err)\n\t}\n\n\tlangVersion := version.Lang(rv)\n\n\truntimeVersion, err := hcversion.NewVersion(strings.TrimPrefix(langVersion, \"go\"))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ttargetedVersion, err := hcversion.NewVersion(TrimGoVersion(goVersion))\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tif runtimeVersion.LessThan(targetedVersion) {\n\t\treturn fmt.Errorf(\"the Go language version (%s) used to build golangci-lint is lower than the targeted Go version (%s)\",\n\t\t\tlangVersion, goVersion)\n\t}\n\n\treturn nil\n}\n\n// TrimGoVersion Trims the Go version to keep only M.m.\n// Since Go 1.21 the version inside the go.mod can be a patched version (ex: 1.21.0).\n// The version can also include information which we want to remove (ex: 1.21alpha1)\n// https://go.dev/doc/toolchain#versions\n// This a problem with staticcheck and gocritic.\nfunc TrimGoVersion(v string) string {\n\tif v == \"\" {\n\t\treturn \"\"\n\t}\n\n\texp := regexp.MustCompile(`(\\d\\.\\d+)(?:\\.\\d+|[a-z]+\\d)`)\n","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/golangci/golangci-lint/blob/ed7a235d2d771152056fdc142a9855567c5796a9/pkg/goutil/version.go#L14-L50","documentation":"CheckGoVersion verifies that the Go language version used to build golangci-lint is not older than the version targeted by the analyzed module's go.mod `go` directive (after TrimGoVersion). This error is returned when runtimeVersion.LessThan(targetedVersion), i.e. the module requires a newer Go than the linter binary supports. go/analysis rejects running analyzers built with an older language version than the target.","triggerScenarios":"Calling CheckGoVersion (via Load) with goVersion from the module's go.mod greater than the linter's build-time Go version — e.g. a module declaring `go 1.24` linted by a golangci-lint binary built with Go 1.23.","commonSituations":"Bumping the go directive in go.mod after adopting a new language feature without upgrading golangci-lint; CI reusing a cached old golangci-lint binary while the repo moved to a newer Go; distro-packaged golangci-lint built with an older toolchain.","solutions":["Upgrade golangci-lint to a version built with a Go toolchain >= the version in your go.mod (`go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest`).","Alternatively lower the `go` directive in go.mod if the newer language version is not actually required.","In CI, install the golangci-lint version matching your Go toolchain instead of a pinned stale binary.","Compare the two versions in the message (linter build version vs targeted version) to pick the right upgrade.","Do not bypass the check; mismatched language versions can make analyzers misbehave."],"exampleFix":"// before (go.mod)\ngo 1.24\n// linted with golangci-lint built with Go 1.23 -> fails\n// after: upgrade the linter binary\n$ go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest  // built with Go 1.24+","handlingStrategy":"validation","validationCode":"// Compare your go.mod's go directive with the linter's build Go version first\nimport hcversion \"github.com/hashicorp/go-version\"\n\nfunc checkToolchainCompat(goDirective, linterBuildGoVersion string) error {\n\tif goDirective == \"\" {\n\t\treturn nil\n\t}\n\ttarget, err1 := hcversion.NewVersion(strings.TrimPrefix(goDirective, \"go\"))\n\tbuild, err2 := hcversion.NewVersion(strings.TrimPrefix(linterBuildGoVersion, \"go\"))\n\tif err1 == nil && err2 == nil && build.LessThan(target) {\n\t\treturn fmt.Errorf(\"upgrade golangci-lint: built with %s, module needs %s\", linterBuildGoVersion, goDirective)\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"if err := goutil.CheckGoVersion(goVersion); err != nil {\n\tif strings.Contains(err.Error(), \"is lower than the targeted Go version\") {\n\t\treturn fmt.Errorf(\"upgrade golangci-lint to a build made with Go >= %s: %w\", goVersion, err)\n\t}\n\treturn err\n}","preventionTips":["When bumping the go directive in go.mod, upgrade golangci-lint in the same change.","In CI, install golangci-lint with a version matching your Go toolchain rather than a stale cached binary.","Run `go version` on the golangci-lint binary and compare against go.mod during setup.","Avoid distro packages built with older toolchains for newer codebases."],"tags":["golang","version-check","compatibility","toolchain"],"backgroundTag":"go-version-mismatch","analyzedSha":"ed7a235d2d771152056fdc142a9855567c5796a9","analyzedAt":"2026-09-02T18:47:33.865Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}