go build_error ai_generated true

go: module example.com/module: directory "/home/user/go/pkg/mod/example.com/[email protected]" not found

ID: go/module-directory-not-found

Also available as: JSON · Markdown · 中文
80%Fix Rate
83%Confidence
0Evidence
2024-06-18First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.11 active — — —
1.12 active — — —
1.13 active — — —
1.14 active — — —
1.15 active — — —
1.16 active — — —
1.17 active — — —
1.18 active — — —
1.19 active — — —
1.20 active — — —
1.21 active — — —
1.22 active — — —
1.23 active — — —

Root Cause

The module cache is missing the required version directory, possibly due to a corrupted cache or incomplete download.

generic

中文

模块缓存缺少所需的版本目录,可能是由于缓存损坏或下载不完整。

Workarounds

  1. 95% success Run 'go clean -modcache' and then 'go mod download'
    go clean -modcache && go mod download
  2. 90% success Run 'go mod tidy' to re-download and verify all dependencies
    go mod tidy

Dead Ends

Common approaches that don't work:

  1. Manually creating the directory and copying files 90% fail

    The module cache is managed by Go; manual creation leads to checksum mismatches and broken references.

  2. Setting GOMODCACHE to a different path without clearing old cache 60% fail

    The new path may not have the required module; the error persists if the module is not downloaded there.