golang/go · error

unrecognized GOARCH %q

Error message

unrecognized GOARCH %q

What it means

Thrown by the script engine's built-in GOARCH prefix condition in DefaultConds. When a script uses [GOARCH:<suffix>] and the suffix neither equals runtime.GOARCH nor is present in internal/syslist.KnownArch, the condition errors instead of returning false. This surfaces misspelled architecture names that would otherwise make a condition line inert.

Source

Thrown at src/cmd/internal/script/conds.go:41

		"runtime.GOOS == <suffix>",
		func(_ *State, suffix string) (bool, error) {
			if suffix == runtime.GOOS {
				return true, nil
			}
			if _, ok := syslist.KnownOS[suffix]; !ok {
				return false, fmt.Errorf("unrecognized GOOS %q", suffix)
			}
			return false, nil
		})

	conds["GOARCH"] = PrefixCondition(
		"runtime.GOARCH == <suffix>",
		func(_ *State, suffix string) (bool, error) {
			if suffix == runtime.GOARCH {
				return true, nil
			}
			if _, ok := syslist.KnownArch[suffix]; !ok {
				return false, fmt.Errorf("unrecognized GOARCH %q", suffix)
			}
			return false, nil
		})

	conds["compiler"] = PrefixCondition(
		"runtime.Compiler == <suffix>",
		func(_ *State, suffix string) (bool, error) {
			if suffix == runtime.Compiler {
				return true, nil
			}
			switch suffix {
			case "gc", "gccgo":
				return false, nil
			default:
				return false, fmt.Errorf("unrecognized compiler %q", suffix)
			}
		})

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Use a valid Go GOARCH value (e.g. amd64, arm64, 386, ppc64le) — see internal/syslist.KnownArch for the full set.
  2. Run the 'help' command in the script engine to list conditions and summaries.
  3. Double-check against 'go tool dist list' output for the canonical spelling.

Example fix

// before
[GOARCH:x86] exec go build
// after
[GOARCH:amd64] exec go build
Defensive patterns

Strategy: validation

Validate before calling

import "internal/syslist"

func validGOARCH(v string) bool {
    _, ok := syslist.KnownArch[v]
    return ok
}

Prevention

When it happens

Trigger: Writing a condition bracket with a misspelled or non-Go architecture, e.g. [GOARCH:x86], [GOARCH:arm64be], or [GOARCH:intel]. The eval closure at conds.go:36-44 is the source.

Common situations: Typo in architecture name; using a vendor marketing name (e.g. 'x86' instead of '386'/'amd64', 'arm64' instead of 'arm64' is valid but 'aarch64' is not); referencing an architecture removed in a newer Go release.

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/afc8130c043cf2b7. Report an issue: GitHub.