{"record":{"id":"875d0760cd9d5318","repo":"golang/go","slug":"error-loading-go-mod-s-d-v","errorCode":null,"errorMessage":"error loading go.mod:\n%s:%d: %v","messagePattern":"error loading go\\.mod:\n(.+?):(.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modload/init.go","lineNumber":1066,"sourceCode":"\t\t\tcontinue\n\t\t}\n\t\tif ld.inWorkspaceMode() && !strings.HasPrefix(cfg.CmdName, \"work \") {\n\t\t\t// Refuse to use workspace if its go version is too old.\n\t\t\t// Disable this check if we are a workspace command like work use or work sync,\n\t\t\t// which will fix the problem.\n\t\t\tmv := gover.FromGoMod(f)\n\t\t\twv := gover.FromGoWork(workFile)\n\t\t\tif gover.Compare(mv, wv) > 0 && gover.Compare(mv, gover.GoStrictVersion) >= 0 {\n\t\t\t\terrs = append(errs, errWorkTooOld(gomod, workFile, mv))\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tif !ld.inWorkspaceMode() {\n\t\t\tok := true\n\t\t\tfor _, g := range f.Godebug {\n\t\t\t\tif err := CheckGodebug(\"godebug\", g.Key, g.Value); err != nil {\n\t\t\t\t\terrs = append(errs, fmt.Errorf(\"error loading go.mod:\\n%s:%d: %v\", base.ShortPath(gomod), g.Syntax.Start.Line, err))\n\t\t\t\t\tok = false\n\t\t\t\t}\n\t\t\t}\n\t\t\tif !ok {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\n\t\tmodFiles = append(modFiles, f)\n\t\tmainModule := f.Module.Mod\n\t\tmainModules = append(mainModules, mainModule)\n\t\tindices = append(indices, indexModFile(data, f, mainModule, fixed))\n\n\t\tif err := module.CheckImportPath(f.Module.Mod.Path); err != nil {\n\t\t\tif pathErr, ok := err.(*module.InvalidPathError); ok {\n\t\t\t\tpathErr.Kind = \"module\"\n\t\t\t}\n\t\t\terrs = append(errs, err)","sourceCodeStart":1048,"sourceCodeEnd":1084,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modload/init.go#L1048-L1084","documentation":"Outside workspace mode, a 'godebug' directive in a go.mod failed CheckGodebug. Reported with the go.mod path and the directive's line number; multiple bad godebug lines accumulate into errs. This is the go.mod analog of error 1066 (which is for go.work).","triggerScenarios":"A module's go.mod has a 'godebug' line whose key/value is malformed or references an unknown/removed setting; ld is NOT in workspace mode so this branch (not the go.work one) runs.","commonSituations":"Module authored against a different Go version that knew a now-removed godebug key; typo in the directive; GODEBUG env value mistakenly committed into go.mod with the wrong format.","solutions":["Edit go.mod at the reported line and fix the key=value pair (no spaces/commas, known key).","Remove the godebug directive if the setting is no longer relevant.","Upgrade the toolchain to a version that still recognizes the key (if it was removed).","Re-run after editing; further godebug lines may be reported in subsequent batches."],"exampleFix":"// before (go.mod line 12)\ngodebug unknownkey=1   // unknown godebug \"unknownkey\"\n\n// after\ngodebug panicnil=0      // a real, known godebug key","handlingStrategy":"validation","validationCode":"// Validate godebug directives in go.mod.\ndata, _ := os.ReadFile(\"go.mod\")\nf, _ := modfile.Parse(\"go.mod\", data, nil)\nfor _, g := range f.Godebug {\n    if err := modload.CheckGodebug(\"godebug\", g.Key, g.Value); err != nil {\n        return fmt.Errorf(\"go.mod godebug %s=%s: %w\", g.Key, g.Value, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"out, err := exec.Command(\"go\", \"build\", \"./...\").CombinedOutput()\nif err != nil && bytes.Contains(out, []byte(\"error loading go.mod\")) && bytes.Contains(out, []byte(\"godebug\")) {\n    return fmt.Errorf(\"invalid godebug in go.mod; fix at reported line: %s\", out)\n}\nreturn err","preventionTips":["Add godebug lines via 'go mod edit -godebug=key=value'.","Validate godebug keys against the toolchain's known list.","Lint go.mod godebug lines for spaces/commas.","On toolchain downgrade, audit now-removed godebug keys."],"tags":["go-mod","godebug","validation"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}