go module_error ai_generated true

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

ID: go/go-mod-tidy-fails-with-module-not-found

Also available as: JSON · Markdown · 中文
92%Fix Rate
83%Confidence
1Evidence
2023-05-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
go1.18 active
go1.19 active
go1.20 active

Root Cause

The specified module version does not exist in the module proxy or upstream repository, often due to a typo in version tag or a deleted release.

generic

中文

指定的模块版本在模块代理或上游仓库中不存在,通常由于版本标签拼写错误或已删除的发布。

Official Documentation

https://go.dev/ref/mod

Workarounds

  1. 95% success Check available versions: go list -m -versions github.com/foo/bar; then use a valid version.
    Check available versions: go list -m -versions github.com/foo/bar; then use a valid version.
  2. 85% success Use the latest version by removing @v1.2.3: go get github.com/foo/bar@latest
    Use the latest version by removing @v1.2.3: go get github.com/foo/bar@latest
  3. 70% success Set GONOSUMCHECK and GONOSUMDB env vars to bypass proxy restrictions: export GONOSUMCHECK=*; export GONOSUMDB=*; then go mod tidy
    Set GONOSUMCHECK and GONOSUMDB env vars to bypass proxy restrictions: export GONOSUMCHECK=*; export GONOSUMDB=*; then go mod tidy

中文步骤

  1. Check available versions: go list -m -versions github.com/foo/bar; then use a valid version.
  2. Use the latest version by removing @v1.2.3: go get github.com/foo/bar@latest
  3. Set GONOSUMCHECK and GONOSUMDB env vars to bypass proxy restrictions: export GONOSUMCHECK=*; export GONOSUMDB=*; then go mod tidy

Dead Ends

Common approaches that don't work:

  1. 90% fail

    -e flag only suppresses error output, module still missing.

  2. 70% fail

    go.sum regeneration requires valid module version; missing version persists.