golang/go · error
missing %s/go.mod at revision %s
Error message
missing %s/go.mod at revision %s
What it means
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.
Source
Thrown at src/cmd/go/internal/modfetch/coderepo.go:915
return "", "", nil, fmt.Errorf("%s has non-...%s module path %q%s at revision %s", file1, r.pathMajor, mpath1, suffix, rev)
}
if _, _, ok := module.SplitPathVersion(mpath1); !ok {
return "", "", nil, fmt.Errorf("%s has malformed module path %q%s at revision %s", file1, mpath1, suffix, rev)
}
return "", "", nil, fmt.Errorf("%s has post-%s module path %q%s at revision %s", file1, semver.Major(version), mpath1, suffix, rev)
}
if r.codeDir == "" && (r.pathMajor == "" || strings.HasPrefix(r.pathMajor, ".")) {
// Implicit go.mod at root of repo OK for v0/v1 and for gopkg.in.
return rev, "", nil, nil
}
// Implicit go.mod below root of repo or at v2+ disallowed.
// Be clear about possibility of using either location for v2+.
if file2 != "" {
return "", "", nil, fmt.Errorf("missing %s/go.mod and ...%s/go.mod at revision %s", r.pathPrefix, r.pathMajor, rev)
}
return "", "", nil, fmt.Errorf("missing %s/go.mod at revision %s", r.pathPrefix, rev)
}
// isMajor reports whether the versions allowed for mpath are compatible with
// the major version(s) implied by pathMajor, or false if mpath has an invalid
// version suffix.
func isMajor(mpath, pathMajor string) bool {
if mpath == "" {
// If we don't have a path, we don't know what version(s) it is compatible with.
return false
}
_, mpathMajor, ok := module.SplitPathVersion(mpath)
if !ok {
// An invalid module path is not compatible with any version.
return false
}
if pathMajor == "" {
// All of the valid versions for a gopkg.in module that requires major
// version v0 or v1 are compatible with the "v0 or v1" implied by an emptyView on GitHub (pinned to b6b368adc5)
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.
Example fix
// before: repo has go.mod at root declaring `module example.com/foo` but you import example.com/foo/v2 // fix upstream go.mod: // module example.com/foo/v2 // then tag v2.0.0 and `go get example.com/foo/v2@v2.0.0`
Defensive patterns
Strategy: validation
Validate before calling
// Before resolving a dependency, confirm the target tag has a go.mod at the
// path the module system expects. Quick check via the proxy:
// curl -s "{proxy}/{module}/@v/{tag}.mod" | head -1
// If the first line is not 'module ...', that revision will throw 1000.
// Prefer picking a tag whose .mod is non-empty before adding to go.mod. Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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'.
Related errors
- can only use path@version syntax with 'go get' and 'go insta
- syntax error
- ${GoModToolVersion} is required for tool directives in go.mo
- disallowed module version
- version %s is not canonical
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/d82cb8d689c6d227.
Report an issue: GitHub.