Report #104513
[bug\_fix] module path mismatch: example.com/mymodule vs example.com/mymodule/v2
Update the module path in go.mod to match the import path. If the module is version v2 or later, the module path must have a \`/v2\` suffix \(e.g., \`example.com/mymodule/v2\`\). Alternatively, if the import path is wrong, change the import statement to match the module path. Run \`go mod tidy\` to synchronize.
Journey Context:
I was working on a Go project that had been upgraded from v1 to v2. The \`go.mod\` file still declared \`module example.com/mymodule\`, but the source code imports were updated to \`example.com/mymodule/v2\`. When building, Go printed \`module path mismatch: example.com/mymodule vs example.com/mymodule/v2\`. I initially thought it was a simple typo in the import paths and double-checked them – they were correct. The environment was a CI pipeline using Go 1.20. I spent an hour searching for why the module path didn't match, even running \`go mod tidy\` which didn't change anything. The root cause is Go's module versioning convention: for major versions >= 2, the module path must include the version suffix. The fix was to change \`go.mod\` to \`module example.com/mymodule/v2\`. After that, \`go build\` succeeded. I also had to update any \`replace\` directives that referenced the old path.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-08-30T20:04:49.828640+00:00— report_created — created