go module_error ai_generated true

go: module github.com/foo/bar@latest: module not found

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

Also available as: JSON · Markdown · 中文
92%Fix Rate
88%Confidence
1Evidence
2023-06-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Go 1.20 active — — —
Go 1.21 active — — —
Go 1.22 active — — —

Root Cause

The specified module version does not exist in the module proxy or repository, often due to a typo or unpublished version.

generic

中文

指定的模块版本在模块代理或仓库中不存在,通常由于拼写错误或版本未发布。

Official Documentation

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

Workarounds

  1. 85% success Verify the module path and version: run 'go list -m github.com/foo/bar@latest' to check if the module exists.
    Verify the module path and version: run 'go list -m github.com/foo/bar@latest' to check if the module exists.
  2. 90% success Use a specific version instead of @latest: 'go get github.com/foo/[email protected]' after confirming the version exists.
    Use a specific version instead of @latest: 'go get github.com/foo/[email protected]' after confirming the version exists.
  3. 75% success Clear module cache and retry: 'go clean -modcache' then 'go mod tidy'
    Clear module cache and retry: 'go clean -modcache' then 'go mod tidy'

中文步骤

  1. Verify the module path and version: run 'go list -m github.com/foo/bar@latest' to check if the module exists.
  2. Use a specific version instead of @latest: 'go get github.com/foo/[email protected]' after confirming the version exists.
  3. Clear module cache and retry: 'go clean -modcache' then 'go mod tidy'

Dead Ends

Common approaches that don't work:

  1. 80% fail

    The -e flag only continues despite errors, but the module still won't be found, leaving the build broken.

  2. 60% fail

    Does not resolve the missing module; go mod tidy will still fail.

  3. 70% fail

    If the module is not found locally or on the proxy, this will not help; it may even worsen the situation by disabling proxy entirely.