{"record":{"id":"941e950d4c66fd48","repo":"go-delve/delve","slug":"too-many-arguments-to-goroutine","errorCode":null,"errorMessage":"too many arguments to goroutine","messagePattern":"too many arguments to goroutine","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/terminal/command.go","lineNumber":977,"sourceCode":"\tif gslen > 0 {\n\t\tfmt.Fprintf(t.stdout, \"[%d goroutines]\\n\", gslen)\n\t}\n\treturn nil\n}\n\nfunc selectedGID(state *api.DebuggerState) int64 {\n\tif state.SelectedGoroutine == nil {\n\t\treturn 0\n\t}\n\treturn state.SelectedGoroutine.ID\n}\n\nfunc (c *Commands) goroutine(t *Term, ctx callContext, argstr string) error {\n\targs := config.Split2PartsBySpace(argstr)\n\n\tif ctx.Prefix == onPrefix {\n\t\tif len(args) != 1 || args[0] != \"\" {\n\t\t\treturn errors.New(\"too many arguments to goroutine\")\n\t\t}\n\t\tctx.Breakpoint.Goroutine = true\n\t\treturn nil\n\t}\n\n\tif len(args) == 1 {\n\t\tif args[0] == \"\" {\n\t\t\treturn printscope(t)\n\t\t}\n\t\tgid, err := strconv.ParseInt(argstr, 10, 64)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\toldState, err := t.client.GetState()\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}","sourceCodeStart":959,"sourceCodeEnd":995,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/terminal/command.go#L959-L995","documentation":"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).","triggerScenarios":"'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.","commonSituations":"Adding flags or a command after 'goroutine' in breakpoint on-actions; passing multiple tokens expecting them to be chained.","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"],"exampleFix":"// before\n(dlv) on 1 goroutine stack\n// after\n(dlv) on 1 goroutine","handlingStrategy":"validation","validationCode":"// Accept only a single argument for goroutine\nargs := strings.Fields(argstr)\nif len(args) > 1 || (onBreakpointAction && len(args) != 0) {\n    return errors.New(\"usage: goroutine [<id> [<command>]]; on-action requires bare 'goroutine'\")\n}","typeGuard":null,"tryCatchPattern":"err := cmds.Goroutine(term, ctx, argstr)\nif err != nil && strings.Contains(err.Error(), \"too many arguments to goroutine\") {\n    fmt.Fprintln(os.Stderr, \"use: 'goroutine <id> <cmd>' or bare 'goroutine' in on-actions\")\n}","preventionTips":["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"],"tags":["terminal","goroutine","cli"],"backgroundTag":"too-many-arguments","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}