Report #13686
[bug\_fix] go: module github.com/example/[email protected] found, but does not contain package github.com/example/lib/v2/models
Update the import path to include the major version suffix in the module path \(e.g., \`github.com/example/lib/v2/models\`\) and update the go.mod requirement to \`github.com/example/lib/v2\`.
Journey Context:
A developer adds a new package from a third-party library that recently released a v2 version. They update the import statement to \`github.com/example/lib/v2/models\` but forget to update the go.mod file, or their IDE auto-imports the v2 package while the go.mod still requires v1.2.0. When they run \`go build\`, Go fetches v1.2.0 \(because it satisfies the \`github.com/example/lib\` requirement without a major version suffix\) and complains that the \`v2/models\` package doesn't exist in v1.2.0. The developer might try clearing the module cache or manually editing go.sum, thinking it's a caching issue. The actual root cause is Go's semantic import versioning rule: major versions \(v2 and above\) must be part of the module path. Because the import path lacked the \`/v2\` suffix in go.mod, Go resolved to the latest v1 version, which naturally doesn't contain the v2 code. Updating the go.mod to require \`github.com/example/lib/v2\` aligns the module resolution with the import path.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T19:24:41.914042+00:00— report_created — created