{"record":{"id":"be2921a5057c6fb7","repo":"golang/go","slug":"value-for-default-must-be-goversion","errorCode":null,"errorMessage":"value for default= must be goVERSION","messagePattern":"value for default= must be goVERSION","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modload/init.go","lineNumber":2297,"sourceCode":"\treturn url + \".v\" + m\n}\n\nfunc 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}","sourceCodeStart":2279,"sourceCodeEnd":2315,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modload/init.go#L2279-L2315","documentation":"Thrown by CheckGodebug for the special key 'default'. The default GODEBUG setting specifies which Go language version's defaults to use and must be of the form 'goVERSION' (e.g. 'go1.22'). The check verifies the value has the 'go' prefix via strings.HasPrefix and that the remainder passes gover.IsValid. If either fails, this error is returned.","triggerScenarios":"A godebug directive 'default=X' where X does not start with 'go' or the part after 'go' is not a valid Go version string. Examples: 'default=1.22' (missing 'go' prefix), 'default=goXYZ' (invalid version), 'default=go' (empty version).","commonSituations":"Typing the version without the 'go' prefix because semver conventions suggest '1.22'. Using a malformed version string. Copy-pasting from documentation that used shorthand.","solutions":["Find the 'godebug default=...' line in go.mod or go.work.","Ensure the value starts with 'go' followed by a valid Go version, e.g. 'go1.22', 'go1.23.1'.","Run 'go mod tidy' or re-run the go command to confirm the file is accepted."],"exampleFix":"// before\ngodebug default=1.22\n\n// after\ngodebug default=go1.22","handlingStrategy":"validation","validationCode":"// Validate a 'default' godebug value.\nfunc validateGodebugDefault(v string) error {\n    if !strings.HasPrefix(v, \"go\") {\n        return fmt.Errorf(\"value for default= must be goVERSION\")\n    }\n    // gover.IsValid checks the version portion\n    if !gover.IsValid(v[len(\"go\"):]) {\n        return fmt.Errorf(\"value for default= must be goVERSION\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always prefix the default version with 'go' (e.g. 'go1.22', not '1.22').","Cross-check the default= value against the 'go' directive in go.mod for consistency.","Use 'go mod edit -godebug=default=go1.22' to set it correctly."],"tags":["godebug","go-version","go-mod","go-work","validation"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}