Report #104421
[bug\_fix] module path mismatch: found example.com/mymodule, but go.mod module path is example.com/mymodule/v2
Update the go.mod file's module directive to match the actual import path used by the package. If the module is at a major version v2 or higher, append the version suffix to the module path \(e.g., \`module example.com/mymodule/v2\`\). Also ensure all import statements in the code use the same path with suffix.
Journey Context:
A developer was migrating a Go module from v1 to v2. They created a new branch and updated the package's import paths in source files to \`example.com/mymodule/v2\`, but forgot to update the \`module\` directive in go.mod, which still read \`module example.com/mymodule\`. When running \`go build\`, Go's module system checked the declared module path against the import paths. The mismatch caused a hard error because Go enforces that the module path in go.mod must be the prefix of all import paths within the module. After a frustrating hour of checking go.sum and cache, the developer ran \`go mod tidy\` which produced the same error, then finally diffed the go.mod against a known-good v2 project and spotted the missing \`/v2\` suffix. The fix is to add the major version suffix to the module path in go.mod per the Go modules specification.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-08-16T20:05:44.556897+00:00— report_created — created