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
- Use one of: -buildvcs, -buildvcs=auto, -buildvjs=true, -buildvcs=false (and the 1/0 shorthands).
- Audit GOFLAGS in your environment (go env GOFLAGS) for a malformed -buildvcs value.
- If driving from a config system, normalize the value through strconv.ParseBool before passing it; map unknown truthy spellings to "auto".
- 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
- Document the accepted -buildvcs values in your build scripts.
- Avoid ad-hoc yes/no/on/off spellings — they are not supported.
- Run `go env GOFLAGS` in CI to catch malformed flag values early.
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
- valid modes are "set", "count", or "atomic"
- build output %q already exists and is a directory
- build output %q already exists and is not an object file
- import path does not begin with hostname
- leading slash
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/8104fde18cae63a4.
Report an issue: GitHub.