Report #40116
[bug\_fix] go: example.com/[email protected]: go.mod declares module as example.com/myrepo/v2 but it was imported as example.com/myrepo
Update all import paths in the consuming code to append the major version suffix \(e.g., example.com/myrepo/v2\), matching the go.mod declaration.
Journey Context:
A developer attempts to upgrade a dependency to its new major version \(v2.0.0\) by simply changing the version string in go.mod. When they run go build, the compiler throws a module path mismatch error. They spend time checking their GOPATH, clearing the module cache, and verifying their go.sum, thinking it's a caching or state issue. However, Go enforces Semantic Import Versioning: if a module is v2 or higher, the major version must be explicitly included in the module path in go.mod AND in every import statement. This ensures v1 and v2 can coexist in the same binary. The fix is to globally update the import paths in the Go source files to include /v2, which aligns the imports with the module's canonical identity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T21:48:28.404264+00:00— report_created — created