Foundations of Debugging for Golang
Author: Matt Boyle (Author)
ASIN : B0D5WS4DV6
Publisher finelybook 出版社: bytesizego.com
Publication Date 出版日期: 2024-7-1.
Language 语言: English
Print length : 180 pages
Book Description
Book Description
By finelybook
Debugging is probably 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.
In this book 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.
Who’s this book for?
This book is aimed at junior and intermediate Go Developers. A working knowledge of Go is assumed.
Table of contents
- Welcome!
- What is Debugging and why do we do it?
- Debugging by eye
- A simple exercise
- Strategies for effective code inspection
- Learning Code patterns and being aware of common errors
- Error handling
- Interfaces
- Concurrency
- Styleguides
- Another Exercise
- Wrapping up
- Pair Programming
- What is pair programming?
- The driver & the navigator
- Switching roles
- The power of two minds
- Accelerating learning and knowledge transfer
- Building rapport & Fostering Communication
- To pair or not to pair?
- Tips for being a great driver
- Tips for being a great navigator
- Pairing remotely
- How I have used pair programming to solve production issues
- Logging
- logging locally with the fmt package
- Upgrading logs with the logs package
- So which should I use for local logging?
- Slog
- Creating a logging strategy
- What should I do with all these logs?
- An exercise
- Wrapping up
- The Debugger
- Setting up the debugger in VScode
- Setting up the debugger in Goland
- Breakpoints
- Debugging panic traces
- Stepping over
- Stepping into
- Conditional breakpoints
- Debugging goroutines
- Tests as an entry point to debugging
- You try – exercise
- Metrics
- Viewing Metrics
- Introduction to PromQL
- Using metrics to help you debug production
- Alerting
- Exercise
- A warning on measuring too much
- Distributed tracing
- Open telemetry
- Adding traces to a Go API
- Adding attributes to spans
- Capturing errors
- Tracing between different services
- Automatic dependency maps
- Tracing beyond http
- Wrapping up and a warning
- Profiling & pprof
- Why profile?
- Adding profiling – the simple way
- Profiling without side effects
- profiling the heap
- CPU profiling and pprof list
- Profiling goroutine usage
- Exercise
- Wrapping up – Should I just leave pprof running all the time.
- Thank you!