From ad9ea63a024419da782e5ee16a102e7a8854b000 Mon Sep 17 00:00:00 2001 From: Moses Narrow <36607567+0pcom@users.noreply.github.com> Date: Tue, 1 Sep 2026 16:04:54 -0500 Subject: [PATCH] builder: suggest GOTOOLCHAIN and -go-compatibility when the host Go is too new The window between a Go release and the TinyGo release that supports it is when most users hit the version gate, and the error gives no way forward. Both escape hatches already exist: GOTOOLCHAIN=go1..x makes the go command download and run a supported toolchain (TinyGo follows it transparently), and -go-compatibility=false skips the check. Mention them in the too-new case; the too-old case keeps the plain message. --- builder/config.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/builder/config.go b/builder/config.go index 4dcc2786e8..192e1f1c48 100644 --- a/builder/config.go +++ b/builder/config.go @@ -38,6 +38,13 @@ func NewConfig(options *compileopts.Options) (*compileopts.Config, error) { if gorootMajor != 1 || gorootMinor < minorMin || gorootMinor > minorMax { // Note: when this gets updated, also update the Go compatibility matrix: // https://github.com/tinygo-org/tinygo-site/blob/dev/content/docs/reference/go-compat-matrix.md + if gorootMajor == 1 && gorootMinor > minorMax { + // A too-new Go toolchain is the common case right after a Go + // release: point at Go's own toolchain switching, which lets + // the user build with a supported toolchain without + // downgrading their installation. + return nil, fmt.Errorf("requires go version 1.%d through 1.%d, got go%d.%d (to use a supported toolchain without downgrading, set GOTOOLCHAIN=go1.%d.x; to skip this check, use -go-compatibility=false)", minorMin, minorMax, gorootMajor, gorootMinor, minorMax) + } return nil, fmt.Errorf("requires go version 1.%d through 1.%d, got go%d.%d", minorMin, minorMax, gorootMajor, gorootMinor) } }