{"record":{"id":"8e1902be9f79315e","repo":"gohugoio/hugo","slug":"go-command-failed-s","errorCode":null,"errorMessage":"go command failed: %s","messagePattern":"go command failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/client.go","lineNumber":820,"sourceCode":"The easiest is to just enter a valid branch name there, e.g. master, which would be what you put in place of 'v0.5.1' in the example below.\n\nrequire github.com/gohugoio/hugo-mod-jslibs/instantpage v0.5.1\n\nIf you then run 'hugo mod graph' it should resolve itself to the most recent version (or commit if no semver versions are available).`)\n\t\t}\n\n\t\t_, ok := err.(*exec.ExitError)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"failed to execute 'go %v': %s %T\", args, err, err)\n\t\t}\n\n\t\t// Too old Go version\n\t\tif strings.Contains(stderr.String(), \"flag provided but not defined\") {\n\t\t\tc.goBinaryStatus = goBinaryStatusTooOld\n\t\t\treturn nil\n\t\t}\n\n\t\treturn fmt.Errorf(\"go command failed: %s\", stderr)\n\n\t}\n\n\treturn nil\n}\n\nvar goOutputReplacer = strings.NewReplacer(\n\t\"go: to add module requirements and sums:\", \"hugo: to add module requirements and sums:\",\n\t\"go mod tidy\", \"hugo mod tidy\",\n)\n\ntype goOutputReplacerWriter struct {\n\tw io.Writer\n}\n\nfunc (w goOutputReplacerWriter) Write(p []byte) (n int, err error) {\n\ts := goOutputReplacer.Replace(string(p))\n\t_, err = w.w.Write([]byte(s))","sourceCodeStart":802,"sourceCodeEnd":838,"githubUrl":"https://github.com/gohugoio/hugo/blob/52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2/modules/client.go#L802-L838","documentation":"The catch-all in runGo for a normal non-zero go exit that did not match the special-cased strings (unknown revision, flag-not-defined/too-old). stderr is forwarded as the message. This is the most common go-side failure surfaced by Hugo module operations — any `go mod`/`go list` exit-code failure that isn't explicitly recognised.","triggerScenarios":"`go mod download`, `go list -m`, `go get`, etc. exit non-zero with stderr that isn't 'invalid version: unknown revision' or 'flag provided but not defined'. Includes sum verification failures, missing go entries, malformed go.mod, compile errors in a module's .go files, network errors during graph walk.","commonSituations":"go.sum out of date, go.mod has syntax errors, a dependency's .go file fails to build under the current toolchain, proxy auth expired, or a replaced local path missing.","solutions":["Read the forwarded stderr verbatim — it is the authoritative cause; act on it directly.","Common fix: `hugo mod tidy` to reconcile go.mod/go.sum.","If it names a missing replace target, fix the replace path in go.mod.","If it names a sum mismatch, `go clean -modcache` then `hugo mod tidy`."],"exampleFix":"// stderr said: missing go.sum entry\n// fix:\nhugo mod tidy\nhugo","handlingStrategy":"validation","validationCode":"// Pre-flight the most common go subcommands Hugo will invoke\nfunc preflightGoModules(projectDir string) error {\n  for _, args := range [][]string{{\"mod\", \"download\"}, {\"list\", \"-m\", \"all\"}} {\n    cmd := exec.Command(\"go\", args...)\n    cmd.Dir = projectDir\n    if out, err := cmd.CombinedOutput(); err != nil {\n      return fmt.Errorf(\"go %s: %s\", strings.Join(args, \" \"), out)\n    }\n  }\n  return nil\n}","typeGuard":"null","tryCatchPattern":"// Treat any 'go command failed:' as authoritative stderr — show it to the user.\n// if strings.HasPrefix(err.Error(), \"go command failed:\") { return errors.New(strings.TrimPrefix(err.Error(), \"go command failed: \")) }","preventionTips":["Keep go.mod/go.sum tidy via `hugo mod tidy` in CI.","Validate replace targets exist.","Pin a working GOPROXY and set GOPRIVATE for private deps.","Regenerate vendor/ when using vendored mode."],"tags":["modules","go-toolchain","hugo-module"],"backgroundTag":null,"analyzedSha":"52c9bd7908b4d02d4d0ff8f82a888834d6ee10d2","analyzedAt":"2026-08-09T21:49:36.660Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}