Report #103779
[bug\_fix] go: github.com/example/[email protected]: parsing go.mod: module declares its path as: github.com/olduser/lib but was required as: github.com/example/lib
Make every import path match the dependency's declared module path exactly \(case, hyphens, slashes, and major-version suffix\). If you renamed or forked the repo, run \`go mod edit -module \` in that module, or add a \`replace github.com/example/lib => ../local/fork\` in the consuming module so the canonical import path is preserved while local code is used. Then run \`go mod tidy\`.
Journey Context:
A teammate replaced a transitive dependency and CI started failing with the path-mismatch error. At first I thought \`go mod tidy\` would rewrite the module directive, but it only adds or removes \`require\` lines; it never changes the \`module\` line. I grepped the module cache and found the downloaded \`go.mod\` still declared the old path. The root cause is that Go uses the \`module\` directive as the canonical identity for a module, and any import must have that path as a prefix. The fix was either to update the import statements to match the declared path \(when the dependency author renamed the module\) or use a \`replace\` directive \(when testing a local fork\). After aligning the paths and running \`go mod tidy\`, the build succeeded.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-13T04:41:30.824716+00:00— report_created — created