{"record":{"id":"6e0663a191ec72aa","repo":"golang/go","slug":"unrecognized-goos-q","errorCode":null,"errorMessage":"unrecognized GOOS %q","messagePattern":"unrecognized GOOS %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/internal/script/conds.go","lineNumber":29,"sourceCode":"\t\"runtime\"\n\t\"sync\"\n)\n\n// DefaultConds returns a set of broadly useful script conditions.\n//\n// Run the 'help' command within a script engine to view a list of the available\n// conditions.\nfunc DefaultConds() map[string]Cond {\n\tconds := make(map[string]Cond)\n\n\tconds[\"GOOS\"] = PrefixCondition(\n\t\t\"runtime.GOOS == <suffix>\",\n\t\tfunc(_ *State, suffix string) (bool, error) {\n\t\t\tif suffix == runtime.GOOS {\n\t\t\t\treturn true, nil\n\t\t\t}\n\t\t\tif _, ok := syslist.KnownOS[suffix]; !ok {\n\t\t\t\treturn false, fmt.Errorf(\"unrecognized GOOS %q\", suffix)\n\t\t\t}\n\t\t\treturn false, nil\n\t\t})\n\n\tconds[\"GOARCH\"] = PrefixCondition(\n\t\t\"runtime.GOARCH == <suffix>\",\n\t\tfunc(_ *State, suffix string) (bool, error) {\n\t\t\tif suffix == runtime.GOARCH {\n\t\t\t\treturn true, nil\n\t\t\t}\n\t\t\tif _, ok := syslist.KnownArch[suffix]; !ok {\n\t\t\t\treturn false, fmt.Errorf(\"unrecognized GOARCH %q\", suffix)\n\t\t\t}\n\t\t\treturn false, nil\n\t\t})\n\n\tconds[\"compiler\"] = PrefixCondition(\n\t\t\"runtime.Compiler == <suffix>\",","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/internal/script/conds.go#L11-L47","documentation":"Thrown by the script engine's built-in GOOS prefix condition (registered via PrefixCondition in DefaultConds). When a script uses [GOOS:<suffix>] and the suffix neither equals runtime.GOOS nor appears in internal/syslist.KnownOS, the condition cannot be evaluated meaningfully, so it errors rather than silently returning false. This catches typos in OS names so test authors do not accidentally skip lines on every platform.","triggerScenarios":"Writing a condition bracket with a misspelled or non-Go OS name, e.g. [GOOS:linnux], [GOOS:macos], or [GOOS:unix]. The eval function in conds.go:24-32 is invoked when the script engine evaluates the bracketed condition before a command.","commonSituations":"Typo in a test script condition; copy-pasting an OS alias that Go does not recognize (e.g. 'macos' instead of 'darwin'); using a vendor-specific name not in Go's target list after a Go upgrade that renamed/removed a port.","solutions":["Correct the suffix to a valid Go GOOS value (e.g. linux, darwin, windows, freebsd) — consult internal/syslist.KnownOS for the complete accepted set.","Run the 'help' command inside the script engine to see registered conditions and their summaries.","If the test should skip on every platform, use a deliberately-false-but-recognized value rather than an unknown one."],"exampleFix":"// before\n[GOOS:linnux] exec go build\n// after\n[GOOS:linux] exec go build","handlingStrategy":"validation","validationCode":"// Before relying on a GOOS condition suffix, confirm it is a known Go OS.\nimport \"internal/syslist\"\n\nfunc validGOOS(v string) bool {\n    _, ok := syslist.KnownOS[v]\n    return ok\n}\n\n// Use when programmatically generating script condition tags:\n//   suffix := \"linux\"\n//   if !validGOOS(suffix) { t.Fatalf(\"bad GOOS %q\", suffix) }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cross-check GOOS spellings against 'go tool dist list' before writing script conditions.","Run the script engine's 'help' command to see registered conditions and accepted suffixes.","Treat an 'unrecognized' error as a typo signal — never ignore it as a normal skip."],"tags":["go-script-test","conditions","goos","go-toolchain"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}