Report #68082
[bug\_fix] go: module github.com/foo/[email protected] found, but does not contain package github.com/foo/bar
Update the import path in your code to include the major version suffix \(e.g., github.com/foo/bar/v2\) and ensure the upstream module's go.mod also declares module github.com/foo/bar/v2.
Journey Context:
A developer runs go get github.com/foo/[email protected] to upgrade a dependency. The go.mod file updates successfully, but running go build immediately fails, claiming the package doesn't exist in the module. The developer inspects the repository on GitHub and sees the code is right there in the root. They clear the module cache \(go clean -modcache\), unset GOPROXY, and try again, but the error persists. The rabbit hole deepens as they suspect a proxy caching issue or a broken tag. The actual root cause is Go's Semantic Import Versioning rule: for modules at v2.0.0 and above, the major version must be appended to the module path. If the upstream go.mod says module github.com/foo/bar but the version tag is v2.1.0, Go treats it as an invalid v0/v1 module. When your code imports github.com/foo/bar, Go's module loader cannot satisfy the import because the required version v2.1.0 dictates a different module path \(github.com/foo/bar/v2\). The fix resolves the mismatch by aligning the import path, the go.mod module declaration, and the version tag under the /v2 suffix.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T20:45:31.303394+00:00— report_created — created