go
build_error
ai_generated
true
go: example.com/[email protected]: 无效的 go 版本 '1.21':必须是 X.Y.Z 格式
go: example.com/[email protected]: invalid go version '1.21': must be X.Y.Z
ID: go/invalid-go-version-in-module
80%修复率
82%置信度
0证据数
2024-04-12首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| 1.21 | active | — | — | — |
| 1.22 | active | — | — | — |
| 1.23 | active | — | — | — |
根因分析
go.mod 中的 'go' 指令指定了一个不符合所需语义版本格式的版本字符串(例如,'1.21' 而不是 '1.21.0')。
English
The 'go' directive in go.mod specifies a version string that does not follow the required semantic versioning format (e.g., '1.21' instead of '1.21.0').
解决方案
-
95% 成功率 Correct the go directive to use proper semantic versioning (e.g., 1.21.0)
Edit go.mod: replace 'go 1.21' with 'go 1.21.0'
-
90% 成功率 Use 'go mod edit -go=1.21.0' to fix it automatically
go mod edit -go=1.21.0
无效尝试
常见但无效的做法:
-
Changing the go directive to a non-existent version like '1.99'
80% 失败
Go only supports releases; non-existent versions cause the toolchain to fail to locate the proper standard library.
-
Removing the go directive entirely
50% 失败
Without a go directive, the module defaults to an older version, potentially causing incompatibilities with newer language features.