go-delve/delve · error
expected argument after -size
Error message
expected argument after -size
What it means
The `-size` flag of the examineMemory command requires a following argument. ParseExamineMemoryArg calls nextArg(); if the flag is the last token on the line (or followed only by whitespace) there is nothing to parse and Delve returns this error immediately.
Source
Thrown at service/api/command.go:249
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 error
out.Size, err = strconv.ParseInt(arg, 0, 64)
if err != nil || out.Size <= 0 || out.Size > 8 {
return nil, errors.New("size must be a positive integer (<=8)")
}
case "-x":
out.IsExpr = true
// remaining args are going to be interpreted as expression
out.Operand = strings.Join(args, " ")
break loop
default:
if len(args) > 0 {
return nil, fmt.Errorf("unknown option %q", args[0])
}
out.Operand = cmd
break loop // only one arg left to be evaluated as a uint
}View on GitHub (pinned to a23773e6c3)
Solutions
- Supply a value after -size, e.g. `x -size 8 <addr>`
- Reorder flags so -size is not last, or remove it if the default size is fine
- Check the client code that assembles the argument string for missing/empty substitutions
Example fix
// before "x -count 4 -size 0xc000010000" // after "x -count 4 -size 8 0xc000010000"
Defensive patterns
Strategy: validation
Validate before calling
if sizeArg == "" {
return fmt.Errorf("-size requires a value")
} Prevention
- Ensure every flag has a trailing value when assembling args
- Interpolate defaults for empty substitutions
- Trim trailing flags from user input
When it happens
Trigger: Invoking `examineMemory` with `-size` as the trailing token, e.g. `x -count 4 -size 0x1000` or `x -size` with no operand at all.
Common situations: Truncated commands from IDE argument builders that drop trailing empty values; hand-typed commands where the size was forgotten; template strings where a substitution was empty.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- count/len must be a positive integer
- size must be a positive integer (<=8)
- no address specified
- too many arguments
- illegal commandline '%s'
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/587df53e4dc5b4db.
Report an issue: GitHub.