# Delve — Interactive Debugger for Go Programs > Delve is a full-featured debugger for Go that understands goroutines, deferred calls, and the Go runtime. It provides breakpoints, variable inspection, expression evaluation, and stack traces for any Go program or test. ## Install Save as a script file and run: # Delve — Interactive Debugger for Go Programs ## Quick Use ```bash go install github.com/go-delve/delve/cmd/dlv@latest dlv debug ./main.go # inside the debugger break main.main continue print myVar ``` ## Introduction Delve is a purpose-built debugger for the Go programming language. Unlike general-purpose debuggers such as GDB, Delve understands Go's concurrency primitives, goroutine scheduling, and runtime internals, giving developers accurate inspection of their programs without the impedance mismatch that comes from adapting C-oriented tools to Go. ## What Delve Does - Sets breakpoints, conditional breakpoints, and tracepoints in Go source code - Inspects local and global variables, struct fields, slices, maps, and interfaces - Evaluates arbitrary Go expressions at runtime - Navigates goroutine stacks and switches between goroutines - Attaches to running processes or core dumps for post-mortem analysis ## Architecture Overview Delve operates as a client-server architecture. The backend (dlv) controls the target process via OS-level ptrace (Linux) or Mach APIs (macOS) and exposes a JSON-RPC or DAP (Debug Adapter Protocol) API. Frontends such as VS Code, GoLand, or the built-in terminal UI connect to this API, making Delve the shared foundation for Go debugging across editors. ## Self-Hosting & Configuration - Install with `go install github.com/go-delve/delve/cmd/dlv@latest` - Works out of the box on Linux (amd64, arm64), macOS, and Windows - Configure via `~/.config/dlv/config.yml` for aliases, source paths, and substitution rules - Supports remote debugging with `dlv --headless --listen=:2345` - Integrates with VS Code through the official Go extension's launch.json ## Key Features - First-class goroutine awareness with per-goroutine stack traces - DAP protocol support for seamless IDE integration - Conditional and hit-count breakpoints for targeted debugging - Core dump analysis for post-mortem debugging - Call injection to execute functions in the debuggee's context ## Comparison with Similar Tools - **GDB** — general-purpose but struggles with Go runtime structures and goroutines - **LLDB** — powerful on macOS but lacks Go-specific support - **GoLand built-in** — uses Delve as its backend under the hood - **VS Code Go debugger** — also powered by Delve via DAP - **print debugging** — zero setup but no interactive inspection or breakpoints ## FAQ **Q: Does Delve support Go generics?** A: Yes, Delve fully supports debugging generic functions and types since Go 1.18. **Q: Can I debug tests with Delve?** A: Yes, use `dlv test ./pkg/...` to debug test binaries directly. **Q: How does remote debugging work?** A: Run `dlv --headless --listen=:2345 exec ./app` on the server, then connect from your local editor to that address. **Q: Does Delve slow down my program?** A: The debuggee runs at near-native speed between breakpoints. Breakpoint hits pause execution, which is standard debugger behavior. ## Sources - https://github.com/go-delve/delve - https://github.com/go-delve/delve/tree/master/Documentation --- Source: https://tokrepo.com/en/workflows/asset-18f5c2c0 Author: Script Depot