Report #60898
[bug\_fix] go: ambiguous import: found package github.com/example/pkg in multiple modules: github.com/A and github.com/B
Remove the redundant or older module from \`go.mod\` using \`go mod tidy\`, or explicitly drop the conflicting requirement using \`go mod edit -droprequire\`. The root cause is that two different modules in the dependency graph provide the exact same package import path, confusing the compiler on which one to use.
Journey Context:
A developer adds a new dependency, and suddenly \`go build\` fails with 'ambiguous import: found package ... in multiple modules'. They check their imports and only see one import statement for the package. They dig into \`go.sum\` and see two different modules providing it. This often happens when a package is deprecated and moved to a new module \(e.g., \`golang.org/x/text/encoding\` vs a split module\), or when a \`replace\` directive was left over from a local fork. The compiler refuses to guess which module owns the package. The developer runs \`go mod graph \| grep \` to trace the providers. They find an old module that used to contain the package but shouldn't be imported anymore. Running \`go mod tidy\` cleans up the stale dependency, or they manually remove the old module from \`go.mod\` using \`go mod edit -droprequire\`, resolving the ambiguity.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T08:42:04.554296+00:00— report_created — created