{"record":{"id":"fdf9b8aa458749bf","repo":"golang/go","slug":"missing-s-go-mod-and-s-go-mod-at-revision-s","errorCode":null,"errorMessage":"missing %s/go.mod and ...%s/go.mod at revision %s","messagePattern":"missing (.+?)/go\\.mod and \\.\\.\\.(.+?)/go\\.mod at revision (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/modfetch/coderepo.go","lineNumber":913,"sourceCode":"\t\t}\n\t\tif r.pathMajor != \"\" { // \".v1\", \".v2\" for gopkg.in\n\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 == \"\" {","sourceCodeStart":895,"sourceCodeEnd":931,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/modfetch/coderepo.go#L895-L931","documentation":"findDir (coderepo.go:910-914). Neither go.mod was found (err1 was NotExist, no major-subdir branch applied or file2 empty), the root-level implicit-go.mod fallback at line 905-908 did not apply (codeDir non-empty OR pathMajor is a real /vN suffix), and file2 was being tracked (the v2 layout would have been considered). Both `<pathPrefix>/go.mod` AND `.../<pathMajor>/go.mod` are missing at the revision. The module simply is not present in the repo at that revision.","triggerScenarios":"Resolving a major-versioned module (/v2) at a revision where neither root go.mod nor /v2/go.mod exists. Common right after a major bump before either file is committed, or for revisions older than the module's introduction.","commonSituations":"Tagging a /v2 version before creating /v2/go.mod; requesting a v2 of a module that has not yet been migrated; pointing replace at a fork that lacks the major-subdir go.mod; old tags predating go.mod adoption.","solutions":["Create the missing go.mod in the source repo (root or /vN subdirectory) at the target revision.","Use a version that actually has a go.mod (`go list -m -versions <module>`).","For replace directives, point at a local directory or fork that contains the proper go.mod.","If v2 is not yet released, depend on v1 or on a pseudo-version derived from a commit that has the file."],"exampleFix":"// before: repo has neither go.mod nor v2/go.mod at v2.0.0 tag\n//   $ go get example.com/m/v2@v2.0.0\n//   missing example.com/m/go.mod and .../v2/go.mod at revision v2.0.0\n\n// after: create v2/go.mod in source repo\n//   v2/go.mod:\n//     module example.com/m/v2\n//     go 1.21\n//   then re-tag and resolve","handlingStrategy":"validation","validationCode":"// Ensure at least one go.mod exists at the target revision.\n// bash:\n//   git ls-tree -r --name-only <rev> | grep -E '(^|/)go.mod$|/v[0-9]+/go.mod$'\n//   # if empty, create one before tagging\n//\n// For a v2 module, confirm v2/go.mod exists:\n//   git cat-file -e <rev>:v2/go.mod || echo 'missing v2/go.mod'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Create the major-subdirectory go.mod BEFORE tagging the first vN release.","For replace directives, point at directories that actually contain a go.mod.","Add a CI check that every major-version tag has a corresponding go.mod."],"tags":["go-modules","go-mod","repository-layout","major-version"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}