Report #58968
[bug\_fix] go: module github.com/foo/[email protected] found, but does not contain package github.com/foo/bar
Update the import path in the source code to include the major version suffix, e.g., \`import "github.com/foo/bar/v2"\`.
Journey Context:
A developer wants to use the latest version of a library and adds \`github.com/foo/bar v2.0.0\` to their \`go.mod\` or runs \`go get github.com/foo/[email protected]\`. The build fails, claiming the package doesn't exist in the module. They check GitHub and clearly see the code is there. They might try clearing the module cache or using \`replace\` directives, which doesn't fix the underlying issue. The root cause is Go's Semantic Import Versioning rule: for modules at v2.0.0 and above, the module path must end with the major version suffix \(\`/v2\`\). The import path must exactly match the module path defined in the dependency's \`go.mod\`. The developer was importing \`github.com/foo/bar\` but the module is actually \`github.com/foo/bar/v2\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T05:28:02.549534+00:00— report_created — created