# go: example.com/module@v1.0.0: 无效的 go 版本 '1.21'：必须是 X.Y.Z 格式

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

## 根因

go.mod 中的 'go' 指令指定了一个不符合所需语义版本格式的版本字符串（例如，'1.21' 而不是 '1.21.0'）。

## 版本兼容性

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

## 解决方案

1. **Correct the go directive to use proper semantic versioning (e.g., 1.21.0)** (95% 成功率)
   ```
   Edit go.mod: replace 'go 1.21' with 'go 1.21.0'
   ```
2. **Use 'go mod edit -go=1.21.0' to fix it automatically** (90% 成功率)
   ```
   go mod edit -go=1.21.0
   ```

## 无效尝试

- **Changing the go directive to a non-existent version like '1.99'** — Go only supports releases; non-existent versions cause the toolchain to fail to locate the proper standard library. (80% 失败率)
- **Removing the go directive entirely** — Without a go directive, the module defaults to an older version, potentially causing incompatibilities with newer language features. (50% 失败率)
