go-delve/delve · error
%s must be followed by an argument
Error message
%s must be followed by an argument
What it means
readGoroutinesFilterKind validates the value that must follow a goroutines filter flag (like -with or -without). If the flag is the last token in the argument list, the required value is missing and this error is thrown. args[i-1] is the flag that needed a value.
Source
Thrown at service/api/command.go:126
filters = append(filters, ListGoroutinesFilter{Kind: GoroutineWaitingOnChannel, Arg: args[i]})
case "-exec":
flags |= PrintGoroutinesExec
cmd = strings.Join(args[i+1:], " ")
i = len(args)
case "":
// nothing to do
default:
return nil, GoroutineGroupingOptions{}, 0, 0, 0, 0, "", fmt.Errorf("wrong argument: '%s'", arg)
}
}
return filters, group, fgl, flags, depth, batchSize, cmd, nil
}
func readGoroutinesFilterKind(args []string, i int) (GoroutineField, error) {
if i >= len(args) {
return GoroutineFieldNone, fmt.Errorf("%s must be followed by an argument", args[i-1])
}
switch args[i] {
case "curloc":
return GoroutineCurrentLoc, nil
case "userloc":
return GoroutineUserLoc, nil
case "goloc":
return GoroutineGoLoc, nil
case "startloc":
return GoroutineStartLoc, nil
case "label":
return GoroutineLabel, nil
case "running":
return GoroutineRunning, nil
case "user":
return GoroutineUser, nil
default:View on GitHub (pinned to a23773e6c3)
Solutions
- Append the filter kind after the flag, e.g. 'goroutines -with label "foo"'.
- Use a valid kind: curloc, userloc, label, function, running, user, file, line.
- If you intended no filter, remove the dangling flag entirely.
Example fix
// before
cmd.ProcessLine("goroutines -with")
// after
cmd.ProcessLine("goroutines -with label worker") Defensive patterns
Strategy: validation
Validate before calling
func hasValueAfter(args []string, i int) bool { return i+1 < len(args) }
// ensure every flag that needs a kind has a following token before calling ParseGoroutineArgs Try / catch
_, _, _, _, _, _, _, err := api.ParseGoroutineArgs(args)
if err != nil {
log.Printf("filter flag missing value: %v", err)
} Prevention
- Never end an argument list with a bare filter flag
- Check for dangling '-' tokens after shell splitting
- Use quoting for values with spaces
When it happens
Trigger: Calling ParseGoroutineArgs or readGoroutinesFilter with a filter flag at the end of the argument list with no following value, e.g. 'goroutines -with label' or 'goroutines -without' (nothing after it).
Common situations: Quoting mistakes that swallow the value; forgetting the filter kind (curloc/userloc/label/function/running/user/file/line); shell splitting removing an empty quoted argument.
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
- illegal commandline '%s'
- unrecognized argument to %s %s
- %s %s needs to be followed by an expression
- %q is not a valid format
- unknown option %q
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/f770131aa3807edf.
Report an issue: GitHub.