# go: 无效的 go 版本 'go1.2x': 必须为 go1.xx 格式

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

## 根因

go.mod 中的 go 指令指定了无效的版本字符串，例如拼写错误或不支持的版本。

## 版本兼容性

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

## 解决方案

1. **Correct the go version to a valid one matching your Go installation.** (95% 成功率)
   ```
   Edit go.mod: change 'go 1.2x' to 'go 1.21' (or your installed version). Run 'go version' to check.
   ```
2. **Use 'go mod edit -go=1.21' to set the correct version.** (90% 成功率)
   ```
   Run: 'go mod edit -go=1.21' to update the directive automatically.
   ```

## 无效尝试

- **Removing the go directive entirely from go.mod.** — Go will default to the current toolchain version, which may cause other compatibility issues. (70% 失败率)
- **Setting a very high go version like 'go1.99' to avoid errors.** — Go only recognizes valid releases; invalid versions cause errors. (100% 失败率)
