# go: 歧义导入：在多个模块中发现包 X：github.com/foo/bar 和 github.com/baz/bar

- **ID:** `go/go-mod-tidy-ambiguous-import`
- **领域:** go
- **类别:** module_error
- **验证级别:** ai_generated
- **修复率:** 82%

## 根因

两个不同的模块提供了相同的导入路径，导致模块解析歧义。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| go1.21 | active | — | — |
| go1.22 | active | — | — |

## 解决方案

1. ```
   在 go.mod 中使用 replace 指令强制指定一个模块：replace github.com/foo/bar => github.com/foo/bar v1.2.3
   ```
2. ```
   重命名冲突的包之一，或通过 vendor 使用不同的导入路径。
   ```

## 无效尝试

- **Running go mod tidy repeatedly hoping it resolves** — go mod tidy cannot resolve ambiguity; it requires manual intervention to specify which module to use. (95% 失败率)
- **Deleting go.sum and re-running go mod download** — Deleting go.sum doesn't fix the import path conflict; it only removes checksums. (80% 失败率)
