go-delve/delve · error
too many arguments to goroutine
Error message
too many arguments to goroutine
What it means
The 'goroutine' command accepts at most one space-separated argument; this error is returned when extra arguments are given, both in the normal path and specifically when used as a breakpoint 'on' action (where only bare 'goroutine' is allowed).
Source
Thrown at pkg/terminal/command.go:977
if gslen > 0 {
fmt.Fprintf(t.stdout, "[%d goroutines]\n", gslen)
}
return nil
}
func selectedGID(state *api.DebuggerState) int64 {
if state.SelectedGoroutine == nil {
return 0
}
return state.SelectedGoroutine.ID
}
func (c *Commands) goroutine(t *Term, ctx callContext, argstr string) error {
args := config.Split2PartsBySpace(argstr)
if ctx.Prefix == onPrefix {
if len(args) != 1 || args[0] != "" {
return errors.New("too many arguments to goroutine")
}
ctx.Breakpoint.Goroutine = true
return nil
}
if len(args) == 1 {
if args[0] == "" {
return printscope(t)
}
gid, err := strconv.ParseInt(argstr, 10, 64)
if err != nil {
return err
}
oldState, err := t.client.GetState()
if err != nil {
return err
}View on GitHub (pinned to a23773e6c3)
Solutions
- Use bare 'goroutine' in on-breakpoint actions: 'on 1 goroutine'
- At the prompt use the form 'goroutine <id> <command>', keeping a single ID argument
- Drop extra arguments; run the additional command separately after switching
Example fix
// before (dlv) on 1 goroutine stack // after (dlv) on 1 goroutine
Defensive patterns
Strategy: validation
Validate before calling
// Accept only a single argument for goroutine
args := strings.Fields(argstr)
if len(args) > 1 || (onBreakpointAction && len(args) != 0) {
return errors.New("usage: goroutine [<id> [<command>]]; on-action requires bare 'goroutine'")
} Try / catch
err := cmds.Goroutine(term, ctx, argstr)
if err != nil && strings.Contains(err.Error(), "too many arguments to goroutine") {
fmt.Fprintln(os.Stderr, "use: 'goroutine <id> <cmd>' or bare 'goroutine' in on-actions")
} Prevention
- In on-breakpoint actions use bare 'goroutine' with no arguments
- Only pass one ID plus optionally one command at the prompt
- Run extra commands separately after switching goroutine
When it happens
Trigger: 'on <bp> goroutine <extra>' with any non-empty argument (only bare 'goroutine' is valid as an on-breakpoint action), or 'goroutine 3 extra' at the prompt.
Common situations: Adding flags or a command after 'goroutine' in breakpoint on-actions; passing multiple tokens expecting them to be chained.
Related errors
- command not available
- you must specify a thread
- not enough arguments
- Invalid frame %d
- Backtick not supported in '%s'
AI-assisted analysis of go-delve/delve@a23773e6c3 (2026-08-31).
Data as JSON: /api/errors/941e950d4c66fd48.
Report an issue: GitHub.