{"record":{"id":"bfa5e9402e7758e8","repo":"golang/go","slug":"parameter-may-not-start-with-quote-character-c","errorCode":null,"errorMessage":"parameter may not start with quote character %c","messagePattern":"parameter may not start with quote character %c","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/load/flag.go","lineNumber":64,"sourceCode":"\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}\n\tf.values = append(f.values, ppfValue{match, flags})\n\treturn nil\n}\n\nfunc (f *PerPackageFlag) String() string { return f.raw }\n","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/load/flag.go#L46-L82","documentation":"The pattern portion of a per-package flag value starts with a single quote (') or double quote (\") character. The parser rejects this because shell quoting and the toolchain's own quoted.Split parser handle quote characters — a quote at the start of the pattern indicates malformed input where shell-level quoting bled into the value.","triggerScenarios":"Passing -gcflags='\"./...\"=-N -l' where the pattern is wrapped in quotes inside the value string, or -ldflags='\"mypkg\"=-s -w'. The first byte of the trimmed value is ' or \".","commonSituations":"Over-quoting in shell commands — wrapping the pattern in quotes when the shell already quotes the entire value. Copy-pasting from documentation or examples that show quotes around patterns. Shell escaping issues with nested quotes.","solutions":["Remove the leading quote character from the pattern portion of the value.","Keep shell quoting only at the outer level: go build -gcflags=\"./...=-N -l\".","Use single quotes for the outer shell value if the inner value contains double quotes."],"exampleFix":"// before — pattern starts with a quote character\ngo build -gcflags='\"./...=-N -l\"'\n// after — no quote on the pattern\ngo build -gcflags=\"./...=-N -l\"","handlingStrategy":"validation","validationCode":"// Check that the pattern portion does not start with a quote.\nfunc validatePerPackageFlag(v string) error {\n    v = strings.TrimSpace(v)\n    if v == \"\" || strings.HasPrefix(v, \"-\") {\n        return nil\n    }\n    if v[0] == '\\'' || v[0] == '\"' {\n        return fmt.Errorf(\"pattern starts with quote: %q\", v)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Apply shell quoting only at the outermost level.","Do not wrap the pattern portion in quotes inside the flag value.","Use single quotes for the outer shell value when the inner value needs double quotes."],"tags":["go","go-build","flags","gcflags","ldflags","shell-quoting"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}