Menu

Post image 1
Post image 2
Post image 3
1 / 3
0

context.Context Is a Tree, Not a Bag. Treat It Like One

DEV Community·Gabriel Anhaia·about 1 month ago
#SnKqRsao
Reading 0:00
15s threshold

Book: The Complete Guide to Go Programming Also by me: Thinking in Go (2-book series) — Complete Guide to Go Programming + Hexagonal Architecture in Go My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools Me: xgabriel.com | GitHub You open a Go service for the first time and grep for ctx.Value . You find a user ID stuffed in there. A request ID. A feature flag. A database transaction. A logger. Some configuration. A correlation token. The signature of every internal function is the same: func doThing(ctx context.Context) error . Everything travels in the bag. It works. Until you trace why a query is reading from a stale replica, and you discover a middleware overrode the transaction key three layers up, and the only way to know that is to read every file between the handler and the repository. context.Context is not a parameter bag. It is a tree.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More