# go: 解析 go.mod 时出错: 意外的 JSON 输入结束

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

## 根因

go.mod 文件格式错误，可能是由于损坏或手动编辑不正确。

## 版本兼容性

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

## 解决方案

1. **Restore go.mod from version control or a backup.** (90% 成功率)
   ```
   Use 'git checkout go.mod' or copy from a known good state.
   ```
2. **Recreate go.mod by running 'go mod init' and re-adding dependencies.** (80% 成功率)
   ```
   Backup current go.mod, delete it, run 'go mod init <module>', then 'go get' each dependency.
   ```

## 无效尝试

- **Running 'go mod tidy' to fix the file.** — Go cannot parse the file to begin with; tidy requires valid syntax. (100% 失败率)
- **Adding random text to the end of go.mod to complete JSON.** — Go.mod is not JSON; it's a custom format. Adding JSON will cause more errors. (100% 失败率)
