{"record":{"id":"d82cb8d689c6d227","repo":"golang/go","slug":"missing-s-go-mod-at-revision-s","errorCode":null,"errorMessage":"missing %s/go.mod at revision %s","messagePattern":"missing (.+?)/go\\.mod at revision (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modfetch/coderepo.go","lineNumber":915,"sourceCode":"\t\t\treturn \"\", \"\", nil, fmt.Errorf(\"%s has non-...%s module path %q%s at revision %s\", file1, r.pathMajor, mpath1, suffix, rev)\n\t\t}\n\t\tif _, _, ok := module.SplitPathVersion(mpath1); !ok {\n\t\t\treturn \"\", \"\", nil, fmt.Errorf(\"%s has malformed module path %q%s at revision %s\", file1, mpath1, suffix, rev)\n\t\t}\n\t\treturn \"\", \"\", nil, fmt.Errorf(\"%s has post-%s module path %q%s at revision %s\", file1, semver.Major(version), mpath1, suffix, rev)\n\t}\n\n\tif r.codeDir == \"\" && (r.pathMajor == \"\" || strings.HasPrefix(r.pathMajor, \".\")) {\n\t\t// Implicit go.mod at root of repo OK for v0/v1 and for gopkg.in.\n\t\treturn rev, \"\", nil, nil\n\t}\n\n\t// Implicit go.mod below root of repo or at v2+ disallowed.\n\t// Be clear about possibility of using either location for v2+.\n\tif file2 != \"\" {\n\t\treturn \"\", \"\", nil, fmt.Errorf(\"missing %s/go.mod and ...%s/go.mod at revision %s\", r.pathPrefix, r.pathMajor, rev)\n\t}\n\treturn \"\", \"\", nil, fmt.Errorf(\"missing %s/go.mod at revision %s\", r.pathPrefix, rev)\n}\n\n// isMajor reports whether the versions allowed for mpath are compatible with\n// the major version(s) implied by pathMajor, or false if mpath has an invalid\n// version suffix.\nfunc isMajor(mpath, pathMajor string) bool {\n\tif mpath == \"\" {\n\t\t// If we don't have a path, we don't know what version(s) it is compatible with.\n\t\treturn false\n\t}\n\t_, mpathMajor, ok := module.SplitPathVersion(mpath)\n\tif !ok {\n\t\t// An invalid module path is not compatible with any version.\n\t\treturn false\n\t}\n\tif pathMajor == \"\" {\n\t\t// All of the valid versions for a gopkg.in module that requires major\n\t\t// version v0 or v1 are compatible with the \"v0 or v1\" implied by an empty","sourceCodeStart":897,"sourceCodeEnd":933,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modfetch/coderepo.go#L897-L933","documentation":"Thrown by codeRepo when a module revision has no go.mod file anywhere it is allowed. For v0/v1 modules at the repo root or gopkg.in paths an implicit go.mod is tolerated, but for v2+ modules (pathMajor set) or modules living in a subdirectory the go command requires an explicit go.mod file at the resolved location. The two-arg variant names both the root and the ...{pathMajor}/go.mod candidate so the author knows either spot is acceptable.","triggerScenarios":"codeRepo.Stat/findDir resolves a revision and discovers file2 == \"\" (only one go.mod slot checked) yet no go.mod exists there; or the v2+ branch where neither root nor major-subdir go.mod is present. Concretely: go get of a tag like v2.3.0 on a repo whose go.mod sits only at root without a /v2 path, or a repo that never adopted modules.","commonSituations":"Importing a v2+ fork whose upstream never added go.mod; depending on a pre-modules project; tag pushed without committing go.mod; module path mismatch between import path and module directive making the discovered go.mod 'not count'.","solutions":["Upgrade the dependency to the lowest version that actually contains an explicit go.mod (check tags on the source repo).","If you control the upstream, run go mod init and ensure the module path includes the /vN suffix matching pathMajor, then tag a new release.","Use a module proxy (GOPROXY=https://proxy.golang.org,direct) which synthesizes a go.mod for legacy repos when the origin lacks one.","Replace with a replace directive pointing at a local clone that has go.mod, or use a fork that ships go.mod."],"exampleFix":"// before: repo has go.mod at root declaring `module example.com/foo` but you import example.com/foo/v2\n// fix upstream go.mod:\n//   module example.com/foo/v2\n// then tag v2.0.0 and `go get example.com/foo/v2@v2.0.0`","handlingStrategy":"validation","validationCode":"// Before resolving a dependency, confirm the target tag has a go.mod at the\n// path the module system expects. Quick check via the proxy:\n//   curl -s \"{proxy}/{module}/@v/{tag}.mod\" | head -1\n// If the first line is not 'module ...', that revision will throw 1000.\n// Prefer picking a tag whose .mod is non-empty before adding to go.mod.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always depend on tags that post-date the upstream go.mod commit.","For v2+ imports verify the module path includes the /vN suffix matching the go.mod directive.","Pin via a standards-compliant GOPROXY so legacy repos get a synthesized go.mod."],"tags":["go-mod","modules","versioning","v2"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}