Delve Go Debugger: Installation, Usage, and Command Reference
This article provides a comprehensive guide to installing and using Delve, the Go‑language source‑level debugger, covering installation methods, command‑line interface, debugging workflows, and practical examples for arrays, slices, and goroutines for developers.
Delve is a source‑level debugger designed specifically for the Go programming language, offering better support for Go runtime, data structures, and expressions than GDB.
Installation can be done by cloning the GitHub repository and building with Go, or directly using go install github.com/go-delve/delve/cmd/dlv@latest on Go 1.16 or later. After installation, the version can be checked with dlv version .
Delve provides a rich command‑line interface. General help is available via dlv --help or dlv [command] --help . Core commands include debug (compile and start debugging a package), attach (connect to a running process), connect (link to a headless debug server), exec (run a precompiled binary), test (debug test binaries), trace (set tracepoints on functions matching a regexp), core (debug a core dump), and dap (start a Debug Adapter Protocol server).
The interactive debugger supports many subcommands grouped by function: program control ( continue / c , next / n , step / s , stepout / so , rebuild , restart / r ), breakpoint manipulation ( break / b , breakpoints / bp , clear , clearall , condition / cond , on , trace / t ), variable and memory inspection ( args , display , examinemem / x , locals , print / p , regs , set , vars , whatis ), goroutine and thread handling ( goroutine / gr , goroutines / grs , thread / tr , threads ), call‑stack navigation ( deferred , frame , stack / bt , up , down ), and miscellaneous utilities ( config , disassemble / disass , edit / ed , exit / quit / q , funcs , help / h , libraries , list / ls / l , source , sources , types ).
Practical examples illustrate debugging arrays and slices: setting a breakpoint on main.main , stepping through initialization, observing how slice length and capacity evolve, and verifying the growth factor change at the 1024‑element threshold.
Another example demonstrates goroutine debugging: launching several goroutines via a sync.WaitGroup , setting a conditional breakpoint on testFunc when i==3 , switching goroutines with goroutine , examining the stack trace with bt , and inspecting function arguments and local variables at specific frames.
The document concludes with a reference to the official Delve repository ( ) and a brief author note.
Yiche Technology
Official account of Yiche Technology, regularly sharing the team's technical practices and insights.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.