{"record":{"id":"c2f47bde7f200d1e","repo":"golang/go","slug":"go-doc-s-v-s","errorCode":null,"errorMessage":"go doc: %s: %v\n%s\n","messagePattern":"go doc: (.+?): (.+?)\n(.+?)\n","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/doc/doc.go","lineNumber":316,"sourceCode":"\t\t\t\tpath, fragment, err := objectPath(userPath, pkg, symbol, method)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\treturn doPkgsite(ctx, path, fragment)\n\t\t\t}\n\t\t\treturn nil\n\t\t}\n\t}\n}\n\nfunc runCmd(env []string, cmdline ...string) (string, error) {\n\tvar stdout, stderr strings.Builder\n\tcmd := exec.Command(cmdline[0], cmdline[1:]...)\n\tcmd.Env = env\n\tcmd.Stdout = &stdout\n\tcmd.Stderr = &stderr\n\tif err := cmd.Run(); err != nil {\n\t\treturn \"\", fmt.Errorf(\"go doc: %s: %v\\n%s\\n\", strings.Join(cmdline, \" \"), err, stderr.String())\n\t}\n\treturn strings.TrimSpace(stdout.String()), nil\n}\n\n// returns a path followed by a fragment (or an error)\nfunc objectPath(userPath string, pkg *Package, symbol, method string) (string, string, error) {\n\tvar err error\n\tpath := pkg.build.ImportPath\n\tif path == \".\" {\n\t\t// go/build couldn't determine the import path, probably\n\t\t// because this was a relative path into a module. Use\n\t\t// go list to get the import path.\n\t\tpath, err = runCmd(nil, \"go\", \"list\", userPath)\n\t\tif err != nil {\n\t\t\treturn \"\", \"\", err\n\t\t}\n\t}\n","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/doc/doc.go#L298-L334","documentation":"Generic wrapper returned by doc.runCmd when an exec.Command it launched (e.g. `go list -m`, `go env GOWORK`) fails. The message embeds the joined command line, the exec error, and the captured stderr so the underlying failure is visible. It is a propagation aid, not a distinct condition.","triggerScenarios":"Any internal helper in go doc that shells out to `go` and the subprocess exits non-zero — module resolution failure, env error, go command crash. The wrapper fires in cmd.Run()'s err branch.","commonSituations":"Broken module state; go command itself misbehaving; env var (GOWORK/GOPATH) misconfiguration; the underlying go invocation hit one of its own errors.","solutions":["Read the embedded stderr in the message to find the real cause.","Reproduce the inner command manually (it is printed) to iterate faster.","Fix the underlying go-list/go-env issue (module tidy, correct GOWORK).","Check `go version` matches the project."],"exampleFix":"# the error already prints the failing command + stderr, e.g.:\n#   go doc: go list -m: exit status 1: <stderr>\n# reproduce and fix the inner command:\n$ go list -m        # see the real error\n$ go mod tidy","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"out, err := runCmd(env, \"go\", \"list\", \"-m\")\nif err != nil {\n    // err already contains the inner command + stderr; surface it verbatim\n    log.Printf(\"doc helper failed: %v\", err)\n}","preventionTips":["Always log the full wrapped message (it carries stderr).","Reproduce the inner command manually to debug faster.","Keep module state tidy so inner go commands succeed."],"tags":["doc","exec","propagation","go-list"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}