go
module_error
ai_generated
partial
导入路径不明确:在多个模块中找到包 example.com/foo: example.com/foo v1.0.0 example.com/foo/v2 v2.1.0
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%修复率
86%置信度
0证据数
2024-07-03首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 1.16+ | active | — | — | — |
| 1.21+ | active | — | — | — |
根因分析
v1 和 v2 模块提供了相同的导入路径,通常是因为 v2 模块未在模块路径中包含 /v2,或被错误地 fork。
English
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.
解决方案
-
85% 成功率
go mod edit -exclude=example.com/[email protected] go mod tidy
-
80% 成功率
go mod edit -replace=example.com/foo=example.com/foo/[email protected] go mod tidy
无效尝试
常见但无效的做法:
-
95% 失败
ambiguity persists; go refuses to pick one
-
90% 失败
does not resolve which module owns the path
-
70% 失败
the module still declares the colliding path