Scripts2026年5月28日·1 分钟阅读

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.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Delve Debugger
直接安装命令
npx -y tokrepo@latest install 18f5c2c0-5ad3-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

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

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产