golang/go · error
parameter may not start with quote character %c
Error message
parameter may not start with quote character %c
What it means
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.
Source
Thrown at src/cmd/go/internal/load/flag.go:64
match := func(_ *modload.Loader, p *Package) bool { return p.Internal.CmdlinePkg || p.Internal.CmdlineFiles } // default predicate with no pattern
// For backwards compatibility with earlier flag splitting, ignore spaces around flags.
v = strings.TrimSpace(v)
if v == "" {
// Special case: -gcflags="" means no flags for command-line arguments
// (overrides previous -gcflags="-whatever").
f.values = append(f.values, ppfValue{match, []string{}})
return nil
}
if !strings.HasPrefix(v, "-") {
i := strings.Index(v, "=")
if i < 0 {
return fmt.Errorf("missing =<value> in <pattern>=<value>")
}
if i == 0 {
return fmt.Errorf("missing <pattern> in <pattern>=<value>")
}
if v[0] == '\'' || v[0] == '"' {
return fmt.Errorf("parameter may not start with quote character %c", v[0])
}
pattern := strings.TrimSpace(v[:i])
match = MatchPackage(pattern, cwd)
v = v[i+1:]
}
flags, err := quoted.Split(v)
if err != nil {
return err
}
if flags == nil {
flags = []string{}
}
f.values = append(f.values, ppfValue{match, flags})
return nil
}
func (f *PerPackageFlag) String() string { return f.raw }
View on GitHub (pinned to b6b368adc5)
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.
Example fix
// before — pattern starts with a quote character go build -gcflags='"./...=-N -l"' // after — no quote on the pattern go build -gcflags="./...=-N -l"
Defensive patterns
Strategy: validation
Validate before calling
// Check that the pattern portion does not start with a quote.
func validatePerPackageFlag(v string) error {
v = strings.TrimSpace(v)
if v == "" || strings.HasPrefix(v, "-") {
return nil
}
if v[0] == '\'' || v[0] == '"' {
return fmt.Errorf("pattern starts with quote: %q", v)
}
return nil
} Prevention
- 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.
When it happens
Trigger: 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 ".
Common situations: 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.
Related errors
- missing =<value> in <pattern>=<value>
- missing <pattern> in <pattern>=<value>
- parse error
- reading %s: %v
- no Go source files
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/bfa5e9402e7758e8.
Report an issue: GitHub.