go
config_error
ai_generated
true
go: 无效的 go 版本 'go1.2x': 必须为 go1.xx 格式
go: invalid go version 'go1.2x': must be of the form go1.xx
ID: go/invalid-go-version-directive
80%修复率
88%置信度
0证据数
2024-05-10首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 1.21 | active | — | — | — |
| 1.22 | active | — | — | — |
| 1.23 | active | — | — | — |
根因分析
go.mod 中的 go 指令指定了无效的版本字符串,例如拼写错误或不支持的版本。
English
The go directive in go.mod specifies an invalid version string, such as a typo or unsupported version.
解决方案
-
95% 成功率 Correct the go version to a valid one matching your Go installation.
Edit go.mod: change 'go 1.2x' to 'go 1.21' (or your installed version). Run 'go version' to check.
-
90% 成功率 Use 'go mod edit -go=1.21' to set the correct version.
Run: 'go mod edit -go=1.21' to update the directive automatically.
无效尝试
常见但无效的做法:
-
Removing the go directive entirely from go.mod.
70% 失败
Go will default to the current toolchain version, which may cause other compatibility issues.
-
Setting a very high go version like 'go1.99' to avoid errors.
100% 失败
Go only recognizes valid releases; invalid versions cause errors.