# go: go.mod 没有模块路径

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

## 根因

go.mod 文件缺少 'module' 指令，该指令用于定义模块的导入路径。

## 版本兼容性

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

## 解决方案

1. **Add the module directive with the correct import path.** (95% 成功率)
   ```
   Edit go.mod to include: 'module github.com/yourusername/yourproject' at the top.
   ```
2. **Reinitialize the module with 'go mod init'.** (90% 成功率)
   ```
   Run 'go mod init github.com/yourusername/yourproject' to generate a proper go.mod.
   ```

## 无效尝试

- **Adding a random module path like 'module example' without proper naming.** — The module path should be a valid import path; random names cause issues later. (60% 失败率)
- **Deleting go.mod and running 'go mod init' without arguments.** — go mod init requires a module path; without it, it prompts for input. (70% 失败率)
