The Tiny Tyrants of Technology • The Applied Go Weekly Newsletter 2025-03-02
Your weekly source of Go news, tips, and projects
The Tiny Tyrants of Technology
Hi ,
How do you debug an app? Do you spread log.Println()
calls across the code or start Delve every time? Or a mix of both, or something else?
There is no single "right" debugging approach, as it depends on the context (as always). If you want to efficiently fight bugs, you need to know what the available techniques are and when and how to use them. To give you a head start over the bugs, I wrote a comprehensive article about debugging techniques; read more in the Spotlight section.
Maybe you expected this week's Spotlight to be a continuation of last week, when I wrote about the start of my explorations of Goose, a local AI agent that (almost) autonomously generated a small web-based service to handle signups. I haven't found the time to examine the results deeper, and I decided to do another, simpler experiment with results that I expect to be easier to verify and discuss in a future spotlight.
So this week's spotlight is about debugging, and (not coincidentally), the Featured Articles section starts wtih some handy debugging tips.
May the bugs stop bugging you!
– Christoph
Featured articles
Tips to debug hanging Go programs - Michael Stapelberg
An app is hanging, and the logs don't reveal why? With these tips by Michael Stapelberg, you should be able to pinpoint the source of the hang without much ado.
How to manage tool dependencies in Go 1.24+ – Alex Edwards
tools.go
and go.run
? Old skool! Go 1.24 redefines tool dependency management. Alex Edward explains how.
Project of the week: Sahilb315/AtomixDB—A persistent relational database built in Go.
A minimalist relational database, but not as minimalist as having no transaction support or concurrent reads.
Podcast corner
go podcast() | 052: Gost, a Go headless browser with Peter Strøiman
In this episode, Peter Strøiman joins Dominic St-Pierre to talk about Gost, a headless browser that is written in Go and does not depend on a headless Chromium instance or other headless browsers.
Cup o' Go: 🧮 Is new math in Go's future? Plus boot.dev update with Lane Wagner
Lane Wagner joins Jonathan Hall as guest... host! Dunno, where's Shay this time? Not on air, but up in the air, perhaps.
Spotlight: On debugging
Bugs are known since the 1870s; at least, the term "bug" was coined at that time, referring to mechanical defects in machinery. Today, we have to fight bugs in software or else our users would lose trust in our apps. Software can become quite complicated, and hence, the art of debugging relies on experience as well as the choice of the right debugging tool.
For the latter, I wrote a blog article about debugging techniques:
Beyond the Debugger: A Comprehensive Guide to Debugging Go Applications
While the article focuses on techniques besides using a debugger, I decided to do the opposite in this Spotlight and entirely focus on using a debugger—Delve in particular.
Delve (dlv) Debugger Cheatsheet for Go
Installation
Refer to your OS's package manager to install an auto-upgradeable dlv
command. Mac users, for example, could run brew install delve
. The following command installs the latest version of Delve in an OS-independent way (albeit without automatic upgrades):
go install github.com/go-delve/delve/cmd/dlv@latest
Getting Started
Delve can start an app from source for debugging, debug unit tests, attach to a running promcess, or debug an already compiled binary:
dlv debug # Debug current package
dlv debug ./path/to/package # Debug specific package
dlv test # Debug tests in current package
dlv attach # Attach to running process
dlv exec ./binary # Debug compiled binary
Basic Commands
Once Delve has started, or attached to, a process, it presents a run-eval-print loop (REPL). A lot of useful commands are available at Delve's internal prompt; here are the basic ones to get started:
help (h) # List available commands
break (b) main.go:15 # Set breakpoint at line 15
breakpoints (bp) # List breakpoints
clear 1 # Remove breakpoint #1
clearall # Remove all breakpoints
continue (c) # Run until next breakpoint
next (n) # Step over to next line
step (s) # Step into function
stepout (so) # Step out of current function
restart (r) # Restart debugging session
exit (q) # Quit debugger
Inspecting Variables
When Delve stops at a breakpoint, you can inspect variables and process arguments, to see how data is processed:
print (p) variableName # Print variable value
locals # Show local variables
args # Show function arguments
vars # Show package variables
whatis variableName # Show variable type
set variableName = value # Change variable value
Call Stack & Goroutines
Examine the context of the current code line: its call stack as well as the current goroutine and other goroutines:
stack (bt) # Show call stack trace
frame 2 # Select stack frame #2
goroutine (gr) # Show current goroutine
goroutines (grs) # List all goroutines
goroutine n # Switch to goroutine n
up # Move up the stack
down # Move down the stack
Function Navigation
You can also put your focus on functions rather than code lines:
funcs regexp # List functions matching regexp
list (l) # Show source code at current position
list main.main # Show source for specific function
Building for Debug
To optimally prepare a program for debugging, disable optimizations (-N
) and inlining of functions (-l
) for all packages:
go build -gcflags="all=-N -l"
Have fun with debugging, but don't blame me if you spend the next hour playing with Delve!
Quote of the Week: Adorable microservices
Microservices are like adopting a puppy—adorable until you’re debugging at 3 a.m.
More articles, videos, talks
Slice Internals in Go: How the Runtime Expands Slices Efficiently
How to grow a dynamic array efficiently? Go's dynamic arrays, a.k.a. slices, use a growth strategy suitable for small and large slices alike.
From Strong to Weak: Weak Pointers in Golang 1.24 - YouTube
Weak pointers explained: Flo Woelki demonstrates implementing a memory-efficient cache using weak pointers, with practical code examples and best practices for effective garbage collection.
Eric Chiang | Protobuf generators for fun and profit
Having stumbled over the shortcomings of OpenAPI and gRPC, Eric Chiang proposes writing custom protobuf generators using protoc plugins and provides an example for generating a plugin that generates Markdown documentation from proto files.
Let's Implement Consistent Hashing From Scratch
Hash tables can have various implementations that are optimized for particular use cases. Consistent hashing is a hashing technique that reduces the amount of key remapping when the map gets resized. – By Sushant Dhiman.
Struct Optimizations in Go
Structs may contain unused space. Mohamed Said explains why and when this unused space occurs, and what to do about it, in the rare case you need to bother about rigidly saving memory.
Projects
Libraries
GitHub - joelseq/sqliteadmin-go: Admin tool for interacting with an embedded SQLite database
Typically, SQLite viewers directly connect to the database file. sqliteadmin
can be used as a library to access the database from within the same application that uses it. No need to get local access to the DB file.
Confetti
Confetti is not new, but it's renewed. Originally kept close to Laravel (the PHP framework), the author overhauled the project to make it more idiomatic.
GitHub - jokruger/gobu: Simple high-performance byte buffers for Go.
A faster alternative to bytes.Buffer
.
Tools and applications
GitHub - tonymajestro/reddit-tui: Terminal UI for reddit
Can't decide whether to use www.reddit.com or old.reddit.com? Well, why use any of these if you can use reddittui
?
Codiew
Most third-party Go playgrounds are wrappers on top of the original Go playground API. Codiew isn't; it runs code in containers supervised by gVisor.
Codiew runs other languages besides Go, too. Try Python, Rust, or PostgreSQL for a change...
GitHub - ndtoan96/gofs
A static file browser with a Web UI that uses only minimal JavaScript—good for older browsers.
Launching DSBG - Automate Your Digital Presence
If Hugo seems overkill for a personal blog, try DSBG—the Dead Simple Blog Generator.
GitHub - karino2/folang: Funcitonal language transpiler to Golang written by Golang (self hosted).
Do you have a few old F# projects to revive? Transpile them to Go, and they'll instantly look F#er!
GitHub - vjerci/gochromecast: A simple tool to stream your media to android TV or chromecast device
Watching telly with Go!
GoTutor
Paste a main package file into the editor, step through the code, and observe how variables, goroutines, and stack frames unfold.
GitHub - 4rkal/crawlr: Find broken links in your website
Crawl your website to find broken links.
Completely unrelated to Go
The Great Social Media Diaspora
"If centralized platforms with their centrally controlled rules and algorithms are “walled gardens,” federated social media might best be described as “community gardens,” shaped by members connected through loose social or geographical ties and a shared interest in maintaining a pleasant community space."
Being on Mastodon (federated) and LinkedIn (centralized), this article sparked my curiosity. While users mass-migrate from centralized to federated platforms to escape the control of algorithms or erratic owners, federation has its own share of problems.
"Decentralization places a heavy burden on individual instance administrators, mostly volunteers, who may lack the tools, time, or capacity to address complex problems effectively."
Centralized or federated? Feels like being caught between a rock and a hard place.
Happy coding! ʕ◔ϖ◔ʔ
Questions or feedback? Drop me a line. I'd love to hear from you.
Best from Munich, Christoph
Not a subscriber yet?
If you read this newsletter issue online, or if someone forwarded the newsletter to you, subscribe for regular updates to get every new issue earlier than the online version, and more reliable than an occasional forwarding.
Find the subscription form at the end of this page.
How I can help
If you're looking for more useful content around Go, here are some ways I can help you become a better Gopher (or a Gopher at all):
On AppliedGo.net, I blog about Go projects, algorithms and data structures in Go, and other fun stuff.
Or visit the AppliedGo.com blog and learn about language specifics, Go updates, and programming-related stuff.
My AppliedGo YouTube channel hosts quick tip and crash course videos that help you get more productive and creative with Go.
Enroll in my Go course for developers that stands out for its intense use of animated graphics for explaining abstract concepts in an intuitive way. Numerous short and concise lectures allow you to schedule your learning flow as you like.
Christoph Berger IT Products and Services
Dachauer Straße 29
Bergkirchen
Germany