golang/go · error

value is neither 'auto' nor a valid bool

Error message

value is neither 'auto' nor a valid bool

What it means

Thrown by buildvcsFlag.Set in cmd/go/internal/work when the -buildvcs flag receives a value that is neither empty, "auto", nor a value strconv.ParseBool accepts (1/0/t/f/T/F/true/false/TRUE/FALSE/True/False). The flag controls whether the go command embeds VCS information (git revision, etc.) into the binary. "auto" is a special go-command extension on top of the usual boolean.

Source

Thrown at src/cmd/go/internal/work/build.go:416

	return "<TagsFlag>"
}

// buildvcsFlag is the implementation of the -buildvcs flag.
type buildvcsFlag string

func (f *buildvcsFlag) IsBoolFlag() bool { return true } // allow -buildvcs (without arguments)

func (f *buildvcsFlag) Set(s string) error {
	// https://go.dev/issue/51748: allow "-buildvcs=auto",
	// in addition to the usual "true" and "false".
	if s == "" || s == "auto" {
		*f = "auto"
		return nil
	}

	b, err := strconv.ParseBool(s)
	if err != nil {
		return errors.New("value is neither 'auto' nor a valid bool")
	}
	*f = buildvcsFlag(strconv.FormatBool(b)) // convert to canonical "true" or "false"
	return nil
}

func (f *buildvcsFlag) String() string { return string(*f) }

// fileExtSplit expects a filename and returns the name
// and ext (without the dot). If the file has no
// extension, ext will be empty.
func fileExtSplit(file string) (name, ext string) {
	dotExt := filepath.Ext(file)
	name = file[:len(file)-len(dotExt)]
	if dotExt != "" {
		ext = dotExt[1:]
	}
	return
}

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Use one of: -buildvcs, -buildvcs=auto, -buildvjs=true, -buildvcs=false (and the 1/0 shorthands).
  2. Audit GOFLAGS in your environment (go env GOFLAGS) for a malformed -buildvcs value.
  3. If driving from a config system, normalize the value through strconv.ParseBool before passing it; map unknown truthy spellings to "auto".
  4. Drop the flag entirely to rely on the default "auto" behavior.

Example fix

# before
GOFLAGS=-buildvcs=on
# after
GOFLAGS=-buildvjs=auto
# or simply
GOFLAGS=-buildvcs
Defensive patterns

Strategy: validation

Validate before calling

func normalizeBuildvcs(s string) (string, error) {
    if s == "" || s == "auto" { return "auto", nil }
    b, err := strconv.ParseBool(s)
    if err != nil { return "", fmt.Errorf("-buildvcs: want auto|true|false, got %q", s) }
    return strconv.FormatBool(b), nil
}

Type guard

func isValidBuildvcs(s string) bool {
    if s == "" || s == "auto" { return true }
    _, err := strconv.ParseBool(s)
    return err == nil
}

Prevention

When it happens

Trigger: Invoking `go build -buildvcs=yes`, `-buildvcs=on`, `-buildvcs=1.0`, or `-buildvcs=maybe`. A Makefile or CI script that sets GOFLAGS=-buildvcs=enabled. A typed-mismatch from a config system that emits "True " with trailing whitespace (ParseBool does not trim).

Common situations: Developers assuming the flag accepts yes/no/on/off common in other tools. Porting scripts from older go versions where the flag did not exist or behaved differently. IDE-generated launch configs with a free-text field.

Related errors


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