go-delve/delve · error
unknown option %q
Error message
unknown option %q
What it means
ParseExamineMemoryArg iterates the argument list and throws this error for an option token it does not recognize while other arguments remain. The unknown token (args[0]) is reported verbatim with %q quoting.
Source
Thrown at service/api/command.go:263
}
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
}
}
if len(out.Operand) == 0 {
return nil, errors.New("no address specified")
}
return &out, nil
}
View on GitHub (pinned to a23773e6c3)
Solutions
- Use only supported options: -fmt/-format, -count/-len, -x and their accepted values.
- Remove or correct the unrecognized token reported in the error message.
- If passing an address, give it as the final bare operand (hex/decimal literal) rather than behind a flag.
Example fix
// before examine-memory -size 8 -x 0xc000010000 // after examine-memory -count 8 -x 0xc000010000
Defensive patterns
Strategy: validation
Validate before calling
var allowedOpts = map[string]bool{"-fmt": true, "-format": true, "-count": true, "-len": true, "-x": true}
// pre-scan tokens; any '-'-prefixed token not in allowedOpts will be rejected
for _, a := range tokens {
if strings.HasPrefix(a, "-") && !allowedOpts[a] { return fmt.Errorf("unknown option %q", a) }
} Try / catch
args, err := api.ParseExamineMemoryArg(argstr)
if err != nil {
return fmt.Errorf("examine-memory rejected args: %v", err)
} Prevention
- Stick to documented flags: -fmt/-format, -count/-len, -x
- Place the address as the final bare operand
- Do not mix gdb-style options with delve's
When it happens
Trigger: Calling ParseExamineMemoryArg with an unknown flag, e.g. 'examine-memory -size 8 0xc000010000' or 'examine-memory -x 0xc000010000' (-x belongs to the expression form only when recognized).
Common situations: Inventing flags like -size or -width; mixing DAP 'examineMemory' option syntax with terminal syntax; forgetting that the raw address must be the last bare argument.
Related errors
- %q is not a valid format
- 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/d7f206582d880349.
Report an issue: GitHub.