Report #39935
[bug\_fix] go: ...: go.mod file indicates module ... but ... was expected
If you are the dependency author, update the module directive in the dependency's go.mod to match the canonical import path. If you are a consumer using a fork, add a replace directive in your go.mod to map the expected path to the fork's actual module path.
Journey Context:
A developer forks a repository to fix a bug, pushes it to github.com/myorg/foo, and updates their go.mod with require github.com/myorg/foo v1.0.0. The build fails, saying the go.mod indicates module github.com/original/foo but github.com/myorg/foo was expected. They try deleting the go.sum or using go get -u, but the error persists. The rabbit hole leads them to think the fork isn't recognized by the Go proxy. The root cause is that Go uses the module directive in go.mod as the canonical identity of the module. If the import path doesn't match the module directive, Go rejects it to prevent dependency confusion. The fix works because the replace directive explicitly tells the Go toolchain when you see this expected path, use this actual module path and version, bridging the identity mismatch without requiring the fork to change its internal go.mod immediately.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T21:30:16.751164+00:00— report_created — created