{"record":{"id":"010f276e7c959a67","repo":"golang/go","slug":"error-loading-go-work-s-d-w","errorCode":null,"errorMessage":"error loading go.work:\n%s:%d: %w","messagePattern":"error loading go\\.work:\n(.+?):(.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modload/init.go","lineNumber":827,"sourceCode":"\t\treturn nil, nil, err\n\t}\n\tseen := map[string]bool{}\n\tfor _, d := range wf.Use {\n\t\tmodRoot := d.Path\n\t\tif !filepath.IsAbs(modRoot) {\n\t\t\tmodRoot = filepath.Join(workDir, modRoot)\n\t\t}\n\n\t\tif seen[modRoot] {\n\t\t\treturn nil, nil, fmt.Errorf(\"error loading go.work:\\n%s:%d: path %s appears multiple times in workspace\", base.ShortPath(path), d.Syntax.Start.Line, modRoot)\n\t\t}\n\t\tseen[modRoot] = true\n\t\tmodRoots = append(modRoots, modRoot)\n\t}\n\n\tfor _, g := range wf.Godebug {\n\t\tif err := CheckGodebug(\"godebug\", g.Key, g.Value); err != nil {\n\t\t\treturn nil, nil, fmt.Errorf(\"error loading go.work:\\n%s:%d: %w\", base.ShortPath(path), g.Syntax.Start.Line, err)\n\t\t}\n\t}\n\n\treturn wf, modRoots, nil\n}\n\n// ReadWorkFile reads and parses the go.work file at the given path.\nfunc ReadWorkFile(path string) (*modfile.WorkFile, error) {\n\tpath = base.ShortPath(path) // use short path in any errors\n\tworkData, err := fsys.ReadFile(path)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"reading go.work: %w\", err)\n\t}\n\n\tf, err := modfile.ParseWork(path, workData, nil)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"errors parsing go.work:\\n%w\", err)\n\t}","sourceCodeStart":809,"sourceCodeEnd":845,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modload/init.go#L809-L845","documentation":"A 'godebug' directive in go.work failed CheckGodebug validation (key/value format). The error is wrapped with file path and line of the offending godebug line so the user can locate it. Distinct from the same check applied to go.mod (error 1070).","triggerScenarios":"go.work has a 'godebug' line whose key or value violates CheckGodebug (whitespace, comma, unknown key, malformed default=goVERSION, etc.). ReadWorkFile/WorkDir flow calls CheckGodebug per entry and reports at g.Syntax.Start.Line.","commonSituations":"Typo in a godebug key; copy-pasting a GODEBUG env var verbatim into a godebug directive (which uses '=' not '='); referencing a godebug setting removed in the current toolchain.","solutions":["Open go.work at the reported line and correct the key/value (one key=value per line, no spaces or commas).","Cross-check the key against 'go doc runtime.GODEBUG' / the official godebug list; remove unknown keys.","For default=, ensure the value is 'go<VERSION>' not exceeding the toolchain version.","Run 'go work sync' or 'go work edit' to re-emit a cleaned go.work if hand-editing is error-prone."],"exampleFix":"// before (go.work line 5)\ngodebug my setting=value     // key has a space\n// error loading go.work: ...: key contains space\n\n// after\ngodebug mysetting=value","handlingStrategy":"validation","validationCode":"// Validate godebug entries in go.work before building.\ndata, _ := os.ReadFile(\"go.work\")\nwf, _ := modfile.ParseWork(\"go.work\", data, nil)\nfor _, g := range wf.Godebug {\n    if err := modload.CheckGodebug(\"godebug\", g.Key, g.Value); err != nil {\n        return fmt.Errorf(\"go.work 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.work\")) && bytes.Contains(out, []byte(\"godebug\")) {\n    // point the user at the offending line; do not retry blindly\n    return fmt.Errorf(\"invalid godebug in go.work; fix line then rebuild: %s\", out)\n}\nreturn err","preventionTips":["Use 'go work edit -godebug=key=value' rather than hand-editing.","Cross-check godebug keys against the Go release notes for your toolchain.","Lint godebug lines for spaces/commas in pre-commit.","One key=value per directive; never paste multi-setting env values."],"tags":["go-work","godebug","validation","workspace"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T08:17:17.861Z"}