Debugging is the most important skill that most people are never taught
Being able to debug locally and in production is a critical skill for any Go engineer, but it is rarely taught explicitly. It has taken me many years of working with Go in production to get comfortable debugging, and I want to accelerate your learning by teaching you everything I wish I had known when I started out.
This book started life as a course and has been written from the ground up, including additional content.
If you are a junior or mid-level Go engineer, I think this book will be useful for you.
What You'll Learn
How to get better at spotting issues by eye.
Logging patterns and how to build an enterprise logging strategy.
What are metrics, how to create them and how to build great dashboards.
What distributed tracing is, and how to set it up in your company.
How to use Go's profiling tools to debug performance issues use and squeeze every ounce of performance out of your application.
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
Tip the Site
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat Pay
Alipay
Open WeChat or Alipay and scan. No login required.
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.
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...
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...
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...
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...
perience, summaries are rarely used and histograms are your best bet for most scenarios. If you want to dig into where summaries might be useful, this5 Stack...
ace2.Tracer But are not using it yet. We’ll use it shortly. Even with this very basic example, you can see some of the promise that distributed tracing can b...
king up 30.73%, which is the thing responsible for handling dynamic memory allocation. You’ll also see on the left StartCpu‐ Profile which is using 35.26%. T...
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.
Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat PayAlipay
Open WeChat or Alipay and scan. No login required.
Add Tag
Enter tag name (max 50 characters)
Share E-Book
Foundations of Debugging for Golang (Matthew Boyle)(Z-Library)
Scan QR code with your phone to access
Copy the link or scan the QR code to access this e-book on your phone
Share E-Book via Email
Please enter email address
Donation Statistics
¥.00
Total Donations
0
Donation Count
Foundations of Debugging for Golang (Matthew Boyle)(Z-Library)
Find Your Favorite Books
Only registered users can comment after logging in. Comments need to be reviewed by administrators before being displayed
Loading comments...
Reply to Comment
Edit Comment