Report #63028
[bug\_fix] go: module example.com/[email protected] found, but does not contain package example.com/foo
Change all import paths from example.com/foo to example.com/foo/v2 and run go mod tidy.
Journey Context:
A developer adds a dependency using go get example.com/[email protected]. The command succeeds and updates go.mod. However, when they build their application, the compiler throws an error stating the package doesn't exist in the module. They check go list -m and see v2.0.0 is indeed downloaded. They clear the module cache, verify their GOPROXY settings, and even check the dependency's GitHub repository to confirm the code exists. The rabbit hole deepens as they suspect a proxy caching issue or a broken module. The actual root cause is Go's Semantic Import Versioning rule: for modules with a major version of 2 or higher, the major version must be explicitly appended to the module path in both the go.mod file and all import statements. The go tool downloaded v2.0.0, but because the import path lacked /v2, it looked for the package at the v1 path within the v2 module, which doesn't exist. Updating the import paths to include /v2 resolves the mismatch.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T12:16:27.250582+00:00— report_created — created