A Quick Introduction to Go Concurrency Primitives

When I first started coding in Go, I vividly recall staring at goroutines and channels for hours, trying to decode the mystery behind them. I had come from a world of analitics and automation in Python where I only recently dipped into asyncio, so Go’s concurrency model and primitives were a whole new world to me. I introduced race conditions, deadlocks, and other subtle bugs into all of my concurrent cod and the context package’s role beyond timeouts was a mystery to me. Slowly I put together enough pieces that I could write and debug concurrent code. ...

December 1, 2024 · 9 min

Implementing a Write-Ahead Log (WAL) in Go

Introduction I love digging into how our everyday tools work under the hood! As a software engineer, I find it incredibly rewarding to peek behind the curtain. It builds my understanding of tools and patterns like nothing else could. Let me show you how to build a Write-Ahead Log (WAL) step-by-step - it’s more than just code, it’s a gateway to understanding the magic that powers our tools. Think about the tools you use every day: databases, version control systems, message queues. They’re all using similar patterns behind the scenes. A WAL is a fundamental building block for all of these tools. When you build this component yourself, you’ll: ...

November 18, 2024 · 15 min

Understanding Atomic Operations in Go

Atomic operations in Go provide a lightweight way to handle concurrent access to simple variables without the overhead of mutexes or the complexity of channels. They also perform significantly better in certain scenarios. While they’re not a silver bullet for all concurrency needs, atomic operations excel in specific scenarios where you need fast, simple synchronization. In this article, we’ll look at: what atomic operations are, how they’re implemented at the instruction set level, when to use them and when not to, as well as some common patterns for using them in code. By the end of reading you should understand when to reach for this valuable concurrency tool instead of better known tools like the sync package, goroutines, and channels. ...

November 12, 2024 · 4 min