LinuxCommandLibrary

dlv

Go programming language debugger

TLDR

Debug an executable

$ dlv exec [./binary]
copy
Debug with arguments
$ dlv exec [./binary] -- [arg1] [arg2]
copy
Debug a Go package
$ dlv debug [package]
copy
Attach to process
$ dlv attach [pid]
copy
Debug a test
$ dlv test [package]
copy
Start headless server
$ dlv debug --headless --listen=:[2345]
copy
Connect to remote
$ dlv connect [localhost:2345]
copy

SYNOPSIS

dlv command [options] [args]

DESCRIPTION

dlv (Delve) is a debugger for the Go programming language. It provides source-level debugging with support for goroutines, breakpoints, variable inspection, and expression evaluation.
Delve understands Go's runtime, correctly handling goroutine scheduling, garbage collection, and other Go-specific features. It supports both local debugging and remote debugging through its headless mode.
The debugger integrates with editors and IDEs via the Debug Adapter Protocol (DAP), enabling graphical debugging in VS Code, GoLand, and other editors.

PARAMETERS

COMMAND

Operation: debug, exec, test, attach, connect, etc.
debug [PACKAGE]
Build and debug Go package.
exec BINARY
Debug prebuilt binary.
test [PACKAGE]
Debug tests.
attach PID
Attach to running process.
connect ADDR
Connect to headless server.
--headless
Run in headless mode.
--listen ADDR
Listen address for headless mode.
--help
Display help information.

CAVEATS

Requires Go binaries with debug info (default). Some optimizations may affect debugging. Attaching to processes needs appropriate permissions. Core dumps require compatible Go version.

HISTORY

Delve was created by Derek Parker and released in 2014. It was developed to provide Go developers with a debugger that understands Go's concurrency model and runtime, replacing GDB for most Go debugging tasks.

SEE ALSO

go(1), gdb(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community