Report #88087
[bug\_fix] module github.com/foo/[email protected] found, but does not contain package github.com/foo/bar/baz
Update the import path to match the major version of the module being resolved \(e.g., github.com/foo/bar/v2/baz\), or pin the dependency in go.mod to the correct major version that contains the package at the imported path.
Journey Context:
A developer updates a dependency with go get -u github.com/foo/bar and their code fails to compile with module github.com/foo/bar found, but does not contain package github.com/foo/bar/baz. They check the repository on GitHub and confirm the baz directory exists on the default branch. They might try clearing the module cache or specifying the version explicitly, but the error remains. The root cause is often a Semantic Import Versioning violation: the developer imported github.com/foo/bar/baz expecting v1, but the go get -u command resolved the latest v2 or v3 tag. Because the author moved the package to github.com/foo/bar/v2/baz in the new major version, the v1 module path doesn't contain the baz package anymore. The fix works because updating the import path to include the major version suffix \(e.g., github.com/foo/bar/v2/baz\) aligns the import with the module's actual structure, allowing the Go toolchain to locate the package within the correct major version directory.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T06:26:13.024279+00:00— report_created — created