go-delve/delve · error
%q is not a valid format
Error message
%q is not a valid format
What it means
ParseExamineMemoryArg parses options for the 'examine-memory' (x) command. The -fmt/-format flag accepts only formats present in fmtMapToPriFmt (hex, octal, decimal, bin/binary, etc.). Any other token after -fmt produces this error. It is a user input validation error, not a debugger state failure.
Source
Thrown at service/api/command.go:233
if arg == "" {
return nil, errors.New("expected argument after -fmt")
}
if arg == "raw" {
out.RawOut = true
} else {
fmtMapToPriFmt := map[string]byte{
"oct": 'o',
"octal": 'o',
"hex": 'x',
"hexadecimal": 'x',
"dec": 'd',
"decimal": 'd',
"bin": 'b',
"binary": 'b',
}
out.Format, ok = fmtMapToPriFmt[arg]
if !ok {
return nil, fmt.Errorf("%q is not a valid format", arg)
}
}
case "-count", "-len":
arg := nextArg()
if arg == "" {
return nil, errors.New("expected argument after -count/-len")
}
var err error
out.Count, err = strconv.ParseInt(arg, 0, 64)
if err != nil || out.Count <= 0 {
return nil, errors.New("count/len must be a positive integer")
}
case "-size":
arg := nextArg()
if arg == "" {
return nil, errors.New("expected argument after -size")
}
var err errorView on GitHub (pinned to a23773e6c3)
Solutions
- Use one of the accepted format names: hex, octal, decimal, bin, binary.
- Check service/api/command.go for the current fmtMapToPriFmt keys - use exactly those strings.
- Omit -fmt to use the default format.
Example fix
// before examine-memory -fmt x 0xc000010000 // after examine-memory -fmt hex 0xc000010000
Defensive patterns
Strategy: validation
Validate before calling
var validFormats = map[string]bool{"hex": true, "octal": true, "decimal": true, "bin": true, "binary": true}
if !validFormats(f) { return fmt.Errorf("unsupported format %q", f) } // check before passing -fmt Try / catch
args, err := api.ParseExamineMemoryArg(argstr)
if err != nil {
return fmt.Errorf("invalid examine-memory args: %v", err)
} Prevention
- Use full format names (hex, decimal, bin), not printf letters
- Consult fmtMapToPriFmt in service/api/command.go for the exact accepted set
- Omit -fmt to fall back to the default format
When it happens
Trigger: Calling ParseExamineMemoryArg or the 'examine-memory' DAP command with e.g. '-fmt float64 0xc000010000' or '-format x addr' - 'x' and 'float64' are not keys in fmtMapToPriFmt.
Common situations: Using printf-style format letters ('x', 'd') instead of full names ('hex', 'decimal'); expecting arbitrary Go format verbs; copying syntax from gdb's x command.
Related errors
- unknown option %q
- illegal commandline '%s'
- %s must be followed by an argument
- unrecognized argument to %s %s
- %s %s needs to be followed by an expression
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/45d21da936d84a73.
Report an issue: GitHub.