# go: 解析 go.mod 时出错：第 3 行出现意外的模块路径 "github.com/foo/bar"：缺少模块声明

- **ID:** `go/malformed-go-mod`
- **领域:** go
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

go.mod 文件格式错误，通常是由于手动编辑不当或合并冲突，缺少 'module' 指令。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.12 | active | — | — |
| 1.18 | active | — | — |

## 解决方案

1. **** (75% 成功率)
   ```
   Add 'module github.com/your/project' at the first line, then run go mod tidy
   ```
2. **** (95% 成功率)
   ```
   git checkout go.mod
   ```

## 无效尝试

- **** — The module path must match the import paths used; a wrong path causes unresolved imports. (80% 失败率)
- **** — This will overwrite the file, losing all existing require statements. (60% 失败率)
