{"record":{"id":"f01b51d446d11af4","repo":"golang/go","slug":"default-s-too-new-toolchain-is-go-s","errorCode":null,"errorMessage":"default=%s too new (toolchain is go%s)","messagePattern":"default=(.+?) too new \\(toolchain is go(.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modload/init.go","lineNumber":2300,"sourceCode":"func CheckGodebug(verb, k, v string) error {\n\tif strings.ContainsAny(k, \" \\t\") {\n\t\treturn fmt.Errorf(\"key contains space\")\n\t}\n\tif strings.ContainsAny(v, \" \\t\") {\n\t\treturn fmt.Errorf(\"value contains space\")\n\t}\n\tif strings.ContainsAny(k, \",\") {\n\t\treturn fmt.Errorf(\"key contains comma\")\n\t}\n\tif strings.ContainsAny(v, \",\") {\n\t\treturn fmt.Errorf(\"value contains comma\")\n\t}\n\tif k == \"default\" {\n\t\tif !strings.HasPrefix(v, \"go\") || !gover.IsValid(v[len(\"go\"):]) {\n\t\t\treturn fmt.Errorf(\"value for default= must be goVERSION\")\n\t\t}\n\t\tif gover.Compare(v[len(\"go\"):], gover.Local()) > 0 {\n\t\t\treturn fmt.Errorf(\"default=%s too new (toolchain is go%s)\", v, gover.Local())\n\t\t}\n\t\treturn nil\n\t}\n\tif godebugs.Lookup(k) != nil {\n\t\treturn nil\n\t}\n\tfor _, info := range godebugs.Removed {\n\t\tif info.Name == k {\n\t\t\tif info.Old(v) {\n\t\t\t\treturn fmt.Errorf(\"removed GODEBUG %q set to old value %q (https://go.dev/doc/godebug#go-1%v)\", k, v, info.Removed)\n\t\t\t}\n\t\t\t// Using a removed GODEBUG setting with a non-old value is ok (see go.dev/issue/76163).\n\t\t\treturn nil\n\t\t}\n\t}\n\treturn fmt.Errorf(\"unknown %s %q\", verb, k)\n}\n","sourceCodeStart":2282,"sourceCodeEnd":2318,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modload/init.go#L2282-L2318","documentation":"Thrown by CheckGodebug when the 'default' GODEBUG key specifies a Go version newer than the running toolchain. After validating the value is a proper goVERSION, it calls gover.Compare against gover.Local() (the toolchain's own version). If the requested default exceeds the toolchain version, the setting is rejected because the toolchain cannot provide defaults for a future Go version.","triggerScenarios":"godebug directive 'default=go1.25' is set but the active toolchain is go1.23. gover.Compare(\"1.25\", \"1.23\") returns > 0, triggering the error. Common when a go.mod targets a newer Go version than the installed toolchain without the toolchain directive auto-downloading a newer toolchain.","commonSituations":"Cloning a project that targets a newer Go version than what is installed. Setting the default GODEBUG manually to match a go.mod 'go' directive that is ahead of the local toolchain. Using an older Go installation.","solutions":["Install or switch to a Go toolchain at or above the version specified in the default= value (use 'go env GOTOOLCHAIN' and the toolchain directive).","Alternatively, lower the default= value in go.mod/go.work to match or be below your current toolchain version.","Ensure GOTOOLCHAIN=auto is set so Go can auto-download the required toolchain."],"exampleFix":"// before (toolchain is go1.22)\ngodebug default=go1.23\n\n// after — let GOTOOLCHAIN=auto fetch go1.23, or downgrade:\ngodebug default=go1.22","handlingStrategy":"validation","validationCode":"// Check default= is not newer than the local toolchain before writing.\nfunc checkDefaultNotTooNew(v string) error {\n    if !strings.HasPrefix(v, \"go\") {\n        return fmt.Errorf(\"value for default= must be goVERSION\")\n    }\n    if gover.Compare(v[len(\"go\"):], gover.Local()) > 0 {\n        return fmt.Errorf(\"default=%s too new (toolchain is go%s)\", v, gover.Local())\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep the default= value at or below the installed toolchain version.","Set GOTOOLCHAIN=auto so Go can fetch the required newer toolchain automatically.","Run 'go version' to check your active toolchain before setting default=."],"tags":["godebug","go-version","toolchain","go-mod","go-work"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}