Report #10161
[bug\_fix] go: module github.com/foo/[email protected] found, but does not contain package github.com/foo/bar
Update the import paths in your code to include the major version suffix \(e.g., \`github.com/foo/bar/v2\`\) and update the \`require\` directive in \`go.mod\` to \`github.com/foo/bar/v2 v2.0.0\`. The root cause is Go's Import Compatibility Rule, which requires modules at major version 2 or higher to have their major version appended to their module path.
Journey Context:
A developer wants to upgrade a dependency from v1.5.0 to v2.0.0 to use new features. They edit \`go.mod\` to change \`require github.com/foo/bar v1.5.0\` to \`require github.com/foo/bar v2.0.0\` and run \`go build\`. The build fails, claiming the module doesn't contain the package. They try \`go get github.com/foo/[email protected]\`, but it results in a pseudo-version or the same error. After reading the modules documentation, they discover the Import Compatibility Rule: if a package's API changes in a breaking way \(major version bump\), it must be treated as a completely different package with a new path. The v2.0.0 tag exists, but the module path in its \`go.mod\` is \`github.com/foo/bar/v2\`. The developer updates all \`import "github.com/foo/bar"\` statements in their codebase to \`import "github.com/foo/bar/v2"\` and updates the \`go.mod\` requirement to \`github.com/foo/bar/v2 v2.0.0\`. The Go toolchain now correctly resolves the v2 module as a distinct namespace, and the build succeeds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T09:55:13.590885+00:00— report_created — created