Report #103415
[bug\_fix] ambiguous import: found package example.com/foo/bar in multiple modules
Add an explicit \`require\` for the module you actually want and, if necessary, a \`replace\` directive to pin it. Run \`go mod tidy\` and \`go mod graph \| grep foo/bar\` to see which modules provide the package; resolve the diamond dependency by upgrading the common ancestor.
Journey Context:
A project depends on module A and module B. Both A and B import \`example.com/foo/bar\`, but A requires v1.2.0 while B requires v1.3.0. \`go build\` fails with \`ambiguous import: found package example.com/foo/bar in multiple modules\`. The developer tries \`go get example.com/foo/bar@latest\`, but the error persists because the ambiguity is about module identity, not version. They run \`go mod graph \| grep foo/bar\` and see two different module paths providing the same package \(often due to a repository rename or a nested module\). They add an explicit \`require example.com/foo v1.3.0\` and a \`replace example.com/foo => example.com/foo v1.3.0\` if a path changed. \`go mod tidy\` collapses the graph to one provider, and the build succeeds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-11T04:21:20.377971+00:00— report_created — created