Delve: How to pass arguments to debugged program?

Created on 2 Jun 2016  路  3Comments  路  Source: go-delve/delve

Please answer the following before submitting your issue:

Note: Please include any substantial examples (debug session output,
stacktraces, etc) as linked gists.

  1. What version of Delve are you using (dlv version)?
    0.11.0-alpha
  2. What version of Go are you using? (go version)?
    1.6.2
  3. What operating system and processor architecture are you using?
    linux/amd64
  4. Issue: How to pass arguments to program?
    I try to add arguments behind the program, but it seems not take effect:
# dlv debug github.com/docker/swarm create
Type 'help' for list of commands.
(dlv) b main.main
Breakpoint 1 set at 0x40100f for main.main() ./src/github.com/docker/swarm/main.go:13
(dlv) c
> main.main() ./src/github.com/docker/swarm/main.go:13 (hits goroutine(1):1 total:1) (PC: 0x40100f)
     8:
     9:         "github.com/docker/swarm/cli"
    10: )
    11:
    12: func main() {
=>  13:         cli.Run()
    14: }
(dlv) n
Usage: debug [OPTIONS] COMMAND [arg...]

A Docker-native clustering system

Version: 1.2.3 (HEAD)

Options:
  --debug                       debug mode [$DEBUG]
  --log-level, -l "info"        Log level (options: debug, info, warn, error, fatal, panic)
  --experimental                enable experimental features
  --help, -h                    show help
  --version, -v                 print the version

Commands:
  create, c     Create a cluster
  list, l       List nodes in a cluster
  manage, m     Manage a docker cluster
  join, j       Join a docker cluster
  help          Shows a list of commands or help for one command

Run 'debug COMMAND --help' for more information on a command.
> main.main() ./src/github.com/docker/swarm/main.go:14 (PC: 0x401014)
     9:         "github.com/docker/swarm/cli"
    10: )
    11:
    12: func main() {
    13:         cli.Run()
=>  14: }

Most helpful comment

Put them after a double dash

dlv debug github.com/docker/swarm -- create

All 3 comments

Put them after a double dash

dlv debug github.com/docker/swarm -- create

I need 3 parameters
autotest -all -w ./
but, this dlv debug autotest/main.go -- -all=true -w=true -template_dir="./" dosn't work, why ?

Put them after a double dash

Does not appear to be documented anywhere nevermind, I see it on the latest version from the general overview:

Pass flags to the program you are debugging using --, for example:

Was this page helpful?
0 / 5 - 0 ratings