go module_error ai_generated true

go:github.com/foo/[email protected]:读取修订版本 v1.2.3 的 go.mod 时出错:未知修订版本 v1.2.3

go: github.com/foo/[email protected]: reading github.com/foo/bar/go.mod at revision v1.2.3: unknown revision v1.2.3

ID: go/go-mod-tidy-wrong-version

其他格式: JSON · Markdown 中文 · English
85%修复率
85%置信度
1证据数
2024-01-20首次发现

版本兼容性

版本状态引入弃用备注
go1.21 active
go1.22 active
go1.23 active

根因分析

请求的模块版本在远程仓库中不存在,通常是由于拼写错误、标签不匹配或标签缺失。

English

The requested module version does not exist in the remote repository, often due to a typo, tag mismatch, or missing tag.

generic

官方文档

https://go.dev/ref/mod#go-mod-tidy

解决方案

  1. Verify the tag exists in the remote repository using 'git ls-remote --tags https://github.com/foo/bar' and correct the version in go.mod.
  2. Use 'go list -m -versions github.com/foo/bar' to list all available versions and choose a valid one.

无效尝试

常见但无效的做法:

  1. Running 'go clean -modcache' and retrying. 95% 失败

    The cache is not the issue; the version truly doesn't exist in the remote repo.

  2. Adding a replace directive in go.mod pointing to a local path. 60% 失败

    This only works if the local path contains the correct code; it doesn't fix the remote version mismatch.