{"record":{"id":"8104fde18cae63a4","repo":"golang/go","slug":"value-is-neither-auto-nor-a-valid-bool","errorCode":null,"errorMessage":"value is neither 'auto' nor a valid bool","messagePattern":"value is neither 'auto' nor a valid bool","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/work/build.go","lineNumber":416,"sourceCode":"\treturn \"<TagsFlag>\"\n}\n\n// buildvcsFlag is the implementation of the -buildvcs flag.\ntype buildvcsFlag string\n\nfunc (f *buildvcsFlag) IsBoolFlag() bool { return true } // allow -buildvcs (without arguments)\n\nfunc (f *buildvcsFlag) Set(s string) error {\n\t// https://go.dev/issue/51748: allow \"-buildvcs=auto\",\n\t// in addition to the usual \"true\" and \"false\".\n\tif s == \"\" || s == \"auto\" {\n\t\t*f = \"auto\"\n\t\treturn nil\n\t}\n\n\tb, err := strconv.ParseBool(s)\n\tif err != nil {\n\t\treturn errors.New(\"value is neither 'auto' nor a valid bool\")\n\t}\n\t*f = buildvcsFlag(strconv.FormatBool(b)) // convert to canonical \"true\" or \"false\"\n\treturn nil\n}\n\nfunc (f *buildvcsFlag) String() string { return string(*f) }\n\n// fileExtSplit expects a filename and returns the name\n// and ext (without the dot). If the file has no\n// extension, ext will be empty.\nfunc fileExtSplit(file string) (name, ext string) {\n\tdotExt := filepath.Ext(file)\n\tname = file[:len(file)-len(dotExt)]\n\tif dotExt != \"\" {\n\t\text = dotExt[1:]\n\t}\n\treturn\n}","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/work/build.go#L398-L434","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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."],"exampleFix":"# before\nGOFLAGS=-buildvcs=on\n# after\nGOFLAGS=-buildvjs=auto\n# or simply\nGOFLAGS=-buildvcs","handlingStrategy":"validation","validationCode":"func normalizeBuildvcs(s string) (string, error) {\n    if s == \"\" || s == \"auto\" { return \"auto\", nil }\n    b, err := strconv.ParseBool(s)\n    if err != nil { return \"\", fmt.Errorf(\"-buildvcs: want auto|true|false, got %q\", s) }\n    return strconv.FormatBool(b), nil\n}","typeGuard":"func isValidBuildvcs(s string) bool {\n    if s == \"\" || s == \"auto\" { return true }\n    _, err := strconv.ParseBool(s)\n    return err == nil\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["go-toolchain","build","flag","vcs","validation"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}