Report #48650
[bug\_fix] go: ...: module path ... does not match import path ...
Update the go.mod file of the local replacement module so that its module path exactly matches the import path specified in the replace directive, or update the replace directive to match the actual module path.
Journey Context:
A developer is working in a monorepo and wants to test a change to a shared library before publishing it. They add a replace directive in their main service's go.mod: \`replace github.com/corp/lib => ../../libs/lib\`. They run \`go build\` and get an error: 'module path github.com/corp/lib does not match import path github.com/corp/lib/v2'. They are confused because the replace directive points to the correct local directory. They inspect the local library's go.mod and see \`module github.com/corp/lib/v2\`. The Go toolchain requires that the module path declared in a module's go.mod must exactly match the module path that the go tool uses to look it up \(the left side of the replace directive\). Because the local library is a v2 module, its path must include \`/v2\`. The fix is to change the replace directive to \`replace github.com/corp/lib/v2 => ../../libs/lib\` and update all imports to use \`github.com/corp/lib/v2\`, ensuring the import path, replace directive, and the local module's go.mod path are all perfectly aligned.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T12:08:14.408267+00:00— report_created — created