go config_error ai_generated true

go: module lookup disabled by GOPROXY=off

ID: go/module-lookup-directory-error

Also available as: JSON · Markdown · 中文
80%Fix Rate
90%Confidence
0Evidence
2024-03-05First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.13 active

Root Cause

The GOPROXY environment variable is set to 'off', disabling all network access for module downloads, but the module is not in the local cache.

generic

中文

GOPROXY 环境变量设置为 'off',禁用了所有模块下载的网络访问,但模块不在本地缓存中。

Workarounds

  1. 95% success
    Set GOPROXY=https://proxy.golang.org,direct in your environment or go env -w GOPROXY=https://proxy.golang.org,direct
  2. 85% success
    If offline, use GOFLAGS=-mod=vendor and ensure all dependencies are vendored with go mod vendor beforehand.

Dead Ends

Common approaches that don't work:

  1. 40% fail

    The environment variable may be overridden by a .env file or Makefile; the shell change may not persist.

  2. 70% fail

    If the module is not already vendored, go mod vendor will still attempt to download it and fail.