Report #56224
[bug\_fix] go: module example.com/[email protected] 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"\), and update the go.mod requirement to example.com/foo/v2 v2.0.0.
Journey Context:
A developer wants to use the latest version of a library, so they run go get example.com/[email protected]. The command succeeds and updates go.mod. However, when they run go build, it fails with 'found, but does not contain package'. They inspect the repository on GitHub and confirm the package exists. They might try clearing the module cache or using a replace directive, thinking the v2 tag is broken. The real issue is the 'Import Compatibility Rule' in Go modules: for major versions v2 and above, the module path must include the major version suffix. The go get command downloaded the v2.0.0 tag, but because the import path in the code lacked /v2, the Go toolchain looked for the package in the root of the v2 module, which might be empty or contain a different package. Updating the import path to example.com/foo/v2 aligns the import with the module's actual path.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T00:51:48.667032+00:00— report_created — created