{"record":{"id":"d9e285a69efdefe0","repo":"golang/go","slug":"missing-value-in-pattern-value","errorCode":null,"errorMessage":"missing =<value> in <pattern>=<value>","messagePattern":"missing =<value> in <pattern>=<value>","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/load/flag.go","lineNumber":58,"sourceCode":"}\n\n// set is the implementation of Set, taking a cwd (current working directory) for easier testing.\nfunc (f *PerPackageFlag) set(v, cwd string) error {\n\tf.raw = v\n\tf.present = true\n\tmatch := func(_ *modload.Loader, p *Package) bool { return p.Internal.CmdlinePkg || p.Internal.CmdlineFiles } // default predicate with no pattern\n\t// For backwards compatibility with earlier flag splitting, ignore spaces around flags.\n\tv = strings.TrimSpace(v)\n\tif v == \"\" {\n\t\t// Special case: -gcflags=\"\" means no flags for command-line arguments\n\t\t// (overrides previous -gcflags=\"-whatever\").\n\t\tf.values = append(f.values, ppfValue{match, []string{}})\n\t\treturn nil\n\t}\n\tif !strings.HasPrefix(v, \"-\") {\n\t\ti := strings.Index(v, \"=\")\n\t\tif i < 0 {\n\t\t\treturn fmt.Errorf(\"missing =<value> in <pattern>=<value>\")\n\t\t}\n\t\tif i == 0 {\n\t\t\treturn fmt.Errorf(\"missing <pattern> in <pattern>=<value>\")\n\t\t}\n\t\tif v[0] == '\\'' || v[0] == '\"' {\n\t\t\treturn fmt.Errorf(\"parameter may not start with quote character %c\", v[0])\n\t\t}\n\t\tpattern := strings.TrimSpace(v[:i])\n\t\tmatch = MatchPackage(pattern, cwd)\n\t\tv = v[i+1:]\n\t}\n\tflags, err := quoted.Split(v)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif flags == nil {\n\t\tflags = []string{}\n\t}","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/load/flag.go#L40-L76","documentation":"Per-package flags (-gcflags, -ldflags, -asmflags, -gccgoflags) use a <pattern>=<flags> syntax when the value does not start with a dash. This error fires when the value contains no '=' character at all, making it impossible to separate the package pattern from the flags. The PerPackageFlag.set method checks for '=' via strings.Index and finds none.","triggerScenarios":"Passing -gcflags=. or -ldflags=myproject — a value that doesn't start with '-' and has no '='. The parser expects either -gcflags=\"-N -l\" (flags apply to command-line packages) or -gcflags=\"./...=-N -l\" (pattern=value syntax).","commonSituations":"Confusing the flag syntax — forgetting the '=' between pattern and flags. Migrating from older Go versions with different flag handling conventions. Shell quoting issues that strip the '='. Typing a bare pattern or package name without flags.","solutions":["If you want flags applied to the packages on the command line, prefix the value with '-': go build -gcflags=\"-N -l\".","If you want flags for a specific package pattern, use <pattern>=<flags>: go build -gcflags=\"runtime=-N -l\".","For all packages in your module: go build -gcflags=\"./...=-N -l\"."],"exampleFix":"// before — no = sign, no leading -\ngo build -gcflags=.\n// after — flags with leading - apply to command-line packages\ngo build -gcflags=\"-N -l\"\n// or — pattern=value syntax\ngo build -gcflags=\"./...=-N -l\"","handlingStrategy":"validation","validationCode":"// Validate per-package flag syntax before passing to go build.\nfunc validatePerPackageFlag(v string) error {\n    v = strings.TrimSpace(v)\n    if v == \"\" || strings.HasPrefix(v, \"-\") {\n        return nil // valid: empty or flags-only form\n    }\n    if !strings.Contains(v, \"=\") {\n        return fmt.Errorf(\"missing =<value> in <pattern>=<value>: %q\", v)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use leading '-' for flags meant for command-line packages: -gcflags=\"-N -l\".","Use pattern=value for package-specific flags: -gcflags=\"runtime=-N -l\".","Test flag syntax in a dry run before CI."],"tags":["go","go-build","flags","gcflags","ldflags","configuration"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T06:17:24.410Z"}