go toolchain_error ai_generated true

go: go.mod requires go >= 1.22.0 (running go 1.21.5; GOTOOLCHAIN=local)

ID: go/toolchain-not-available

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

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1.21+ active — — —
1.22+ active — — —

Root Cause

go.mod declares a newer Go version than the installed toolchain, and GOTOOLCHAIN=local prevents automatic toolchain download.

generic

中文

go.mod 声明的 Go 版本高于已安装的工具链,且 GOTOOLCHAIN=local 阻止自动下载工具链。

Workarounds

  1. 95% success
    GOTOOLCHAIN=auto go build ./...
  2. 90% success
    go install golang.org/dl/go1.22.0@latest
    ~/go/bin/go1.22.0 download
    ~/go/bin/go1.22.0 build ./...

Dead Ends

Common approaches that don't work:

  1. 60% fail

    may use language features unavailable in 1.21, causing compile errors

  2. 100% fail

    off is not a valid value; use local

  3. 100% fail

    the build does not proceed