AI guide
【One-Line Pitch】
A practical, hands-on guide for junior and mid-level Go engineers who want to master debugging—from spotting bugs by eye and using IDE debuggers to building a full production observability stack with logging, metrics, and distributed tracing.
【Book Arc】
- **Opening (~0%–11%)**: Introduces debugging as a core skill and starts with "debugging by eye"—training readers to spot common Go bugs (like off-by-one errors in slices) through code inspection exercises, emphasizing that the compiler doesn't catch everything.
- **Early (~11%–26%)**: Covers collaborative debugging techniques, focusing on pair programming as a growth tool—when to use it (tricky issues, onboarding, knowledge sharing) and practical tips for both driver and navigator roles, including remote pairing etiquette.
- **Early (~26%–33%)**: Dives into logging fundamentals, starting with `fmt` and `log` packages, then transitioning to `slog` for structured JSON logging. Builds toward an enterprise logging strategy: log at the "edge" (main, handlers), use only Info/Error levels, and centralize logs in tools like Kibana.
- **Middle (~41%–52%)**: Moves to the interactive debugger—setting up VSCode and Goland, using breakpoints, stepping over/into, conditional breakpoints, and debugging goroutines. Includes a hands-on exercise with a broken HTTP server to practice real debugging.
- **Late (~52%–end)**: Shifts to production debugging, starting with metrics—what they are, Prometheus types, adding them to Go apps, and using PromQL for querying and alerting. The book then covers distributed tracing with OpenTelemetry, including spans, attributes, error capture, and cross-service tracing.
【Key Takeaways】
- **Debugging by eye is a trainable skill** (Opening): Learning code patterns and common error types helps you spot bugs before running code; the compiler doesn't catch everything, so reading code carefully is a powerful first line of defense.
- **Pair programming accelerates debugging skills** (Early): Fresh perspectives on tricky issues and structured driver/navigator roles improve code quality and knowledge transfer; remote pairing requires patience and clear communication.
- **Structured logging with `slog` is production-ready** (Early): JSON-formatted logs with key-value attributes make logs machine-readable and queryable; use `LogAttrs` to attach consistent metadata across all log entries.
- **Keep logging strategy simple: Info and Error only** (Early): Default to Error level, enable Info via environment variable when needed; log at the application edge (main, handlers) to reduce noise and centralize error handling.
- **Log aggregation is non-negotiable for production** (Early): Pushing logs to Kibana or similar tools enables querying, dashboards, and alerting—the minimum observability setup before serving customers.
- **IDE debuggers handle concurrency challenges** (Middle): Goroutines make debugging unpredictable, but conditional breakpoints and goroutine inspection in VSCode/Goland let you pause execution precisely where issues occur.
- **Metrics turn production debugging from reactive to proactive** (Late): Tracking measurements like payment failures or login errors helps detect issues early; Prometheus types and PromQL enable querying and alerting on anomalies.
【Reading Tips】
- **Skim the early code inspection exercises** (Opening–Early): They're quick and build intuition; try to spot the bug before reading the solution to train your eye.
- **Deep-read the logging strategy chapter** (Early ~26%–33%): The advice on log levels, edge logging, and aggregation is directly applicable to real projects—take notes on the `slog` patterns.
- **Follow along with the debugger setup** (Middle ~41%–52%): Set up VSCode or Goland as you read; the screenshots and step-by-step instructions are meant to be replicated, not just read.
- **Don't skip the exercises**: The HTTP server debugging exercise and the Kibana logging exercise are where the skills stick—allocate time to complete them.
- **Treat the production section as a roadmap** (Late): Metrics and tracing chapters are more conceptual; skim if you're not deploying yet, but bookmark them for when you need to build observability.
【Coverage Limits】
Excerpts cover local debugging (by eye, pairing, logging, debugger) and the start of production debugging (metrics, tracing), but do not include the book's later sections on profiling tools or performance optimization.
Passage locations
Page 10
You Try - Exercise 74 DEBUGGING IN PRODUCTION 1. METRICS 79 What are Metrics? 80 Categories of Metrics 80 Prometheus metric types 82 Adding metrics to a Go A...
View in text
Excerpt 2
mbers. T I P S FO R B E I N G A G R E AT D R I V E R 1. Stay Focused: As the driver, your primary responsibility is to write the code. Stay focused on the ta...
View in text
Excerpt 3
having two log levels in your application, Info and Error. By default, your log level should be set to Error, but you can enable Info by switching an environ...
View in text
Excerpt 4
g a breakpoint on wg.Wait() doesn’t necessarily help. Below is a screenshot from Goland once we pause execution. Here we can see a menu for the first time; t...
View in text