Report #76929
[bug\_fix] go: module github.com/foo/bar/[email protected] found, but does not contain package github.com/foo/bar
Update all import statements for the upgraded dependency to include the \`/v2\` suffix \(e.g., \`import "github.com/foo/bar/v2"\`\), then run \`go mod tidy\` to align go.mod with the new imports.
Journey Context:
A developer wants to upgrade a dependency from v1 to v2. They run \`go get github.com/foo/[email protected]\`, which successfully updates \`go.mod\`. However, when they run \`go build\`, it fails with 'found, but does not contain package'. They are confused because \`go get\` just downloaded it. They try deleting the module cache, but the error persists. The rabbit hole leads them to the Semantic Import Versioning \(SIV\) rule in Go. If a module's \`go.mod\` declares a major version suffix \(e.g., \`module github.com/foo/bar/v2\`\), all import paths consuming that module must also include the \`/v2\` suffix. The developer's code still had \`import "github.com/foo/bar"\`, which the compiler interpreted as a request for the v1 package. The fix works because adding the \`/v2\` suffix explicitly tells the Go toolchain to resolve the import using the v2 module path, matching the \`go.mod\` directive and ensuring version compatibility.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T11:43:10.961470+00:00— report_created — created