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

Also available as: JSON · Markdown · 中文
80%Fix Rate
86%Confidence
0Evidence
2024-07-03First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
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

  1. 85% success
    go mod edit -exclude=example.com/[email protected]
    go mod tidy
  2. 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:

  1. 95% fail

    ambiguity persists; go refuses to pick one

  2. 90% fail

    does not resolve which module owns the path

  3. 70% fail

    the module still declares the colliding path