Report #49991
[bug\_fix] go: module example.com/foo/v2 found, but does not contain package example.com/foo
Update the import path in the Go source code to include the major version suffix \(e.g., \`import "example.com/foo/v2"\`\), matching the module path defined in the dependency's go.mod.
Journey Context:
A developer adds a new major version of a dependency using \`go get example.com/foo/v2\`. The go.mod updates correctly, but the build fails claiming the package isn't found within the module. They might try clearing the module cache \(\`go clean -modcache\`\), running \`go mod tidy\`, or checking their GOPROXY, but the issue persists. The root cause is that Go's semantic import versioning rule requires the import statement in the .go file to exactly match the module path for major versions >= v2. Since the code still has \`import "example.com/foo"\`, the compiler looks for that path inside the v2 module, which doesn't exist \(the module root is v2\). Updating the import path resolves the mismatch because it tells the compiler exactly which module and sub-path to resolve.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T14:23:34.116002+00:00— report_created — created