Report #103781
[bug\_fix] ambiguous import: found package example.com/a/x in multiple modules: example.com/a v0.1.0 example.com/a/x v0.1.0
Inspect the graph with \`go mod graph \| grep example.com/a\` and \`go mod why -m example.com/a/x\`. Ensure only one module in the build list provides the package. If a library carved the package out into a submodule, upgrade the parent to a version that no longer contains it at the same time, e.g. \`go get example.com/[email protected] example.com/a/[email protected]\`. Remove or correct stale \`replace\`/\`require\` lines, and regenerate \`vendor/\` if vendoring.
Journey Context:
We split a subpackage out of a large module into its own module. Locally everything built because we used \`replace\` directives in a workspace, but once the consuming service picked up real versions it failed with \`ambiguous import\`. \`go mod graph\` showed that both \`example.com/[email protected]\` \(which still contained the subpackage\) and the new \`example.com/a/[email protected]\` were in the build list. The root cause is that Go requires a unique provider for every package path. The fix was to release \`example.com/[email protected]\` with the subpackage removed and update the consumer to require both new versions together, so only \`example.com/a/x\` provided the package.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-13T04:41:43.291621+00:00— report_created — created