go
module_error
ai_generated
partial
ambiguous import: found package example.com/foo in multiple modules: example.com/foo v1.0.0 example.com/foo/v2 v2.1.0
ID: go/ambiguous-import-path
80%Fix Rate
86%Confidence
0Evidence
2024-07-03First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.16+ | active | — | — | — |
| 1.21+ | active | — | — | — |
Root Cause
Both a v1 and v2 module provide the same import path, usually because the v2 module failed to include /v2 in its module path or was forked incorrectly.
generic中文
v1 和 v2 模块提供了相同的导入路径,通常是因为 v2 模块未在模块路径中包含 /v2,或被错误地 fork。
Workarounds
-
85% success
go mod edit -exclude=example.com/[email protected] go mod tidy
-
80% success
go mod edit -replace=example.com/foo=example.com/foo/[email protected] go mod tidy
Dead Ends
Common approaches that don't work:
-
95% fail
ambiguity persists; go refuses to pick one
-
90% fail
does not resolve which module owns the path
-
70% fail
the module still declares the colliding path