go
module_error
ai_generated
true
go: ambiguous import: found package X in multiple modules: Y and Z
ID: go/ambiguous-import
80%Fix Rate
85%Confidence
0Evidence
2024-11-15First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 1.18 | active | — | — | — |
| 1.19 | active | — | — | — |
Root Cause
Multiple modules provide the same import path, causing ambiguity.
generic中文
同一个包路径被多个模块提供,导致导入歧义。
Workarounds
-
70% success 使用replace指令指定一个模块
replace example.com/pkg => github.com/user/module v1.0.0
-
60% success 更新导入路径使用完整模块路径
import "github.com/user/module/pkg"
Dead Ends
Common approaches that don't work:
-
删除其中一个模块
60% fail
可能两个模块都是必需的,删除会导致其他依赖问题。
-
使用go mod tidy
90% fail
go mod tidy不会解决歧义,只会报告错误。