golang/go · error

condition %q requires a suffix

Error message

condition %q requires a suffix

What it means

Thrown by Engine.conditionsActive when a condition registered as a prefix Cond (PrefixCondition or CachedCondition, which have Prefix==true) is used in a bracket without the required ':suffix' (engine.go:531-533). Prefix conditions need an argument to be meaningful, so the bare form is rejected before Eval.

Source

Thrown at src/cmd/internal/script/engine.go:532

func (e *Engine) conditionsActive(s *State, conds []condition) (bool, error) {
	for _, cond := range conds {
		var impl Cond
		prefix, suffix, ok := strings.Cut(cond.tag, ":")
		if ok {
			impl = e.Conds[prefix]
			if impl == nil {
				return false, fmt.Errorf("unknown condition prefix %q; known: %v", prefix, slices.Collect(maps.Keys(e.Conds)))
			}
			if !impl.Usage().Prefix {
				return false, fmt.Errorf("condition %q cannot be used with a suffix", prefix)
			}
		} else {
			impl = e.Conds[cond.tag]
			if impl == nil {
				return false, fmt.Errorf("unknown condition %q", cond.tag)
			}
			if impl.Usage().Prefix {
				return false, fmt.Errorf("condition %q requires a suffix", cond.tag)
			}
		}
		active, err := impl.Eval(s, suffix)

		if err != nil {
			return false, fmt.Errorf("evaluating condition %q: %w", cond.tag, err)
		}
		if active != cond.want {
			return false, nil
		}
	}

	return true, nil
}

func (e *Engine) runCommand(s *State, cmd *command, impl Cmd) error {
	if impl == nil {
		return cmdError(cmd, errors.New("unknown command"))

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Add the required ':value' suffix, e.g. [GOOS:linux].
  2. Run 'help' to see whether the condition is shown as [name:*] (prefix) or [name] (bool).
  3. If you wanted an unconditional check, pick a bool condition instead.

Example fix

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

Strategy: validation

Validate before calling

func requiresSuffix(conds map[string]script.Cond, tag string) bool {
    c, ok := conds[tag]
    return ok && c.Usage().Prefix
}

Prevention

When it happens

Trigger: Writing [GOOS], [GOARCH], [GODEBUG], or [buildmode] without the colon and value, e.g. [GOARCH] cmd instead of [GOARCH:amd64] cmd.

Common situations: Forgetting the suffix on a prefix condition; assuming a condition is boolean when it is parameterized; truncating a condition during copy-paste.

Related errors


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