{"record":{"id":"addcb8a68eb1e3fb","repo":"golang/go","slug":"unrecognized-goexperiment-q","errorCode":null,"errorMessage":"unrecognized GOEXPERIMENT %q","messagePattern":"unrecognized GOEXPERIMENT %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/internal/script/scripttest/conditions.go","lineNumber":115,"sourceCode":"}\n\nfunc hasGoexperiment(s *script.State, value string) (bool, error) {\n\tGOOS, _ := s.LookupEnv(\"GOOS\")\n\tGOARCH, _ := s.LookupEnv(\"GOARCH\")\n\tgoexp, _ := s.LookupEnv(\"GOEXPERIMENT\")\n\tflags, err := buildcfg.ParseGOEXPERIMENT(GOOS, GOARCH, goexp)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\tfor _, exp := range flags.All() {\n\t\tif value == exp {\n\t\t\treturn true, nil\n\t\t}\n\t\tif strings.TrimPrefix(value, \"no\") == strings.TrimPrefix(exp, \"no\") {\n\t\t\treturn false, nil\n\t\t}\n\t}\n\treturn false, fmt.Errorf(\"unrecognized GOEXPERIMENT %q\", value)\n}\n","sourceCodeStart":97,"sourceCodeEnd":117,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/internal/script/scripttest/conditions.go#L97-L117","documentation":"Thrown by the GOEXPERIMENT prefix condition registered by scripttest.AddToolChainScriptConditions (conditions.go:99-116). It parses the current GOEXPERIMENT env via buildcfg.ParseGOEXPERIMENT, then checks the queried value against all enabled flags. If the value matches no flag (even negated via 'no'), it is unrecognized and errors. This catches references to experiments that do not exist for the current GOOS/GOARCH.","triggerScenarios":"Writing [GOEXPERIMENT:bogusflag] cmd where 'bogusflag' is not a real experiment; referencing an experiment that was renamed or removed in the current Go version; using an experiment not valid for the target GOOS/GOARCH.","commonSituations":"Experiment dropped between Go releases (e.g. fieldtrack, regabi in transition); typo in the experiment name; experiment only available on specific architectures.","solutions":["Consult internal/buildcfg or run with an empty GOEXPERIMENT to list valid flags for the platform.","Remove the condition line if the experiment no longer exists.","Gate experiment-specific tests behind a Go-version check so they do not reference stale names."],"exampleFix":"// before\n[GOEXPERIMENT:fieldtrack] exec go build\n// after (experiment removed)\n[!GOEXPERIMENT:fieldtrack] skip \"fieldtrack no longer exists\"\n// or simply remove the line","handlingStrategy":"validation","validationCode":"import \"internal/buildcfg\"\n\nfunc validGOEXPERIMENT(goos, goarch, goexp, value string) bool {\n    flags, err := buildcfg.ParseGOEXPERIMENT(goos, goarch, goexp)\n    if err != nil {\n        return false\n    }\n    for _, exp := range flags.All() {\n        if value == exp || strings.TrimPrefix(value, \"no\") == strings.TrimPrefix(exp, \"no\") {\n            return true\n        }\n    }\n    return false\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Experiment names change across Go versions — re-validate after upgrades.","Parse GOEXPERIMENT via buildcfg to enumerate valid flags before referencing them in conditions.","Remove conditions for dropped experiments rather than leaving stale references."],"tags":["go-script-test","conditions","goexperiment","go-toolchain"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}