{"record":{"id":"2b57878d9168d7eb","repo":"golang/go","slug":"invalid-s-value-q","errorCode":null,"errorMessage":"invalid %s value %q","messagePattern":"invalid (.+?) value %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/envcmd/env.go","lineNumber":664,"sourceCode":"\tcase \"GOENV\", \"GODEBUG\":\n\t\treturn fmt.Errorf(\"%s can only be set using the OS environment\", key)\n\t}\n\n\t// To catch typos and the like, check that we know the variable.\n\t// If it's already in the env file, we assume it's known.\n\tif !cfg.CanGetenv(key) {\n\t\treturn fmt.Errorf(\"unknown go command variable %s\", key)\n\t}\n\n\t// Some variables can only have one of a few valid values. If set to an\n\t// invalid value, the next cmd/go invocation might fail immediately,\n\t// even 'go env -w' itself.\n\tswitch key {\n\tcase \"GO111MODULE\":\n\t\tswitch val {\n\t\tcase \"\", \"auto\", \"on\", \"off\":\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"invalid %s value %q\", key, val)\n\t\t}\n\tcase \"GOPATH\":\n\t\tif strings.HasPrefix(val, \"~\") {\n\t\t\treturn fmt.Errorf(\"GOPATH entry cannot start with shell metacharacter '~': %q\", val)\n\t\t}\n\t\tif !filepath.IsAbs(val) && val != \"\" {\n\t\t\treturn fmt.Errorf(\"GOPATH entry is relative; must be absolute path: %q\", val)\n\t\t}\n\tcase \"GOMODCACHE\":\n\t\tif !filepath.IsAbs(val) && val != \"\" {\n\t\t\treturn fmt.Errorf(\"GOMODCACHE entry is relative; must be absolute path: %q\", val)\n\t\t}\n\tcase \"CC\", \"CXX\":\n\t\tif val == \"\" {\n\t\t\tbreak\n\t\t}\n\t\targs, err := quoted.Split(val)\n\t\tif err != nil {","sourceCodeStart":646,"sourceCodeEnd":682,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/envcmd/env.go#L646-L682","documentation":"Returned by checkEnvWrite's value-validation switch when a key that only accepts enumerated values is given something outside the allowed set. Currently fires for GO111MODULE with values other than \"\", \"auto\", \"on\", \"off\".","triggerScenarios":"`go env -w GO111MODULE=enable`, `go env -w GO111MODULE=yes`, `go env -w GO111MODULE=true`, or any value not in {\"\", auto, on, off}.","commonSituations":"Users assuming boolean syntax (true/false, yes/no, 1/0) for GO111MODULE; copy-paste from tutorials using non-canonical values; migration scripts that blindly forward old config.","solutions":["Use one of the documented values: \"\", \"auto\", \"on\", or \"off\".","In module-aware Go (1.16+), prefer leaving GO111MODULE unset (defaults to on) rather than forcing a value.","If migrating from GOPATH mode, set GO111MODULE=on explicitly only while transitioning."],"exampleFix":"# before\n$ go env -w GO111MODULE=true\nerror: invalid GO111MODULE value \"true\"\n# after\n$ go env -w GO111MODULE=on","handlingStrategy":"validation","validationCode":"var go111Valid = map[string]bool{\"\": true, \"auto\": true, \"on\": true, \"off\": true}\nif key == \"GO111MODULE\" && !go111Valid[val] {\n    return fmt.Errorf(\"GO111MODULE must be one of '', auto, on, off; got %q\", val)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default to leaving GO111MODULE unset on modern Go.","Use only the canonical values; never boolean synonyms.","Document acceptable values next to any config helper that sets GO111MODULE."],"tags":["config","env","validation","modules"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}