{"record":{"id":"b72b759792a29dd7","repo":"golang/go","slug":"maximum-supported-go-version-is-s","errorCode":null,"errorMessage":"maximum supported Go version is %s","messagePattern":"maximum supported Go version is (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modcmd/tidy.go","lineNumber":99,"sourceCode":"// A goVersionFlag is a flag.Value representing a supported Go version.\n//\n// (Note that the -go argument to 'go mod edit' is *not* a goVersionFlag.\n// It intentionally allows newer-than-supported versions as arguments.)\ntype goVersionFlag struct {\n\tv string\n}\n\nfunc (f *goVersionFlag) String() string { return f.v }\nfunc (f *goVersionFlag) Get() any       { return f.v }\n\nfunc (f *goVersionFlag) Set(s string) error {\n\tif s != \"\" {\n\t\tlatest := gover.Local()\n\t\tif !modfile.GoVersionRE.MatchString(s) {\n\t\t\treturn fmt.Errorf(\"expecting a Go version like %q\", latest)\n\t\t}\n\t\tif gover.Compare(s, latest) > 0 {\n\t\t\treturn fmt.Errorf(\"maximum supported Go version is %s\", latest)\n\t\t}\n\t}\n\n\tf.v = s\n\treturn nil\n}\n\nfunc runTidy(ctx context.Context, cmd *base.Command, args []string) {\n\tmoduleLoader := modload.NewLoader()\n\tif len(args) > 0 {\n\t\tbase.Fatalf(\"go: 'go mod tidy' accepts no arguments\")\n\t}\n\n\t// Tidy aims to make 'go test' reproducible for any package in 'all', so we\n\t// need to include test dependencies. For modules that specify go 1.15 or\n\t// earlier this is a no-op (because 'all' saturates transitive test\n\t// dependencies).\n\t//","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modcmd/tidy.go#L81-L117","documentation":"Thrown by goVersionFlag.Set when the provided Go version is structurally valid (passes GoVersionRE) but is higher than the currently running toolchain version (`gover.Local()`). The go command refuses to set a go.mod directive to a version newer than itself, since it cannot guarantee correct behavior. Note that the type comment says it 'intentionally allows newer-than-supported versions as arguments' but this specific check blocks versions strictly greater than the local toolchain.","triggerScenarios":"Running `go mod tidy -go=1.30` when the installed Go toolchain is 1.22. `gover.Compare(s, latest)` returns > 0, triggering the error with the local toolchain's version.","commonSituations":"Upgrading go.mod to a version after a colleague used a newer Go; running an older Go toolchain on a project that targets a newer version; CI environment with an older Go than the local development machine.","solutions":["Install or upgrade to the required Go toolchain version, then re-run the command","Use `go mod tidy -go=<latest>` where latest is at or below the installed Go version (shown in the error message)","Set GOTOOLCHAIN to auto-download the needed version: `GOTOOLCHAIN=go1.30.0 auto go mod tidy -go=1.30`"],"exampleFix":"// before (with Go 1.22 installed)\ngo mod tidy -go=1.30\n// after\nGOTOOLCHAIN=auto go mod tidy -go=1.30","handlingStrategy":"validation","validationCode":"import (\n    \"golang.org/x/mod/gover\"\n)\n\nfunc validateGoVersionNotTooNew(s string) error {\n    if gover.Compare(s, gover.Local()) > 0 {\n        return fmt.Errorf(\"version %s exceeds local toolchain %s; upgrade Go or use GOTOOLCHAIN=auto\", s, gover.Local())\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the Go toolchain updated to match project requirements","Set GOTOOLCHAIN=auto in CI to auto-download newer toolchains","Document the minimum Go version in the project README or go.mod"],"tags":["go","go-mod","version","toolchain","compatibility"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}