Exceptions vs Error Values: How to Pick a Strategy

Open a file that doesn鈥檛 exist in Python and open() raises a FileNotFoundError that unwinds out of your function. Do the same thing in Go and os.ReadFile hands back an error value sitting next to a nil byte slice. Same failure, two different shapes of code around it. The difference is not cosmetic. It decides whether a caller can ignore the failure by accident, and whether the compiler notices when they do. ...

October 26, 2026 路 8 min 路 1506 words 路 SpaghettiCoder

Goroutines and Channels Explained With Examples

Put go in front of a function call and it runs concurrently with the rest of your program, scheduled by the Go runtime instead of the OS. Starting one is the easy part. The hard part is getting two goroutines to hand off a result without stepping on each other鈥檚 state, and that鈥檚 the job channels do. What is a goroutine? A goroutine is a function running independently of the one that started it, managed by Go鈥檚 runtime rather than the operating system. An OS thread reserves a megabyte or more of stack and costs the kernel real time to schedule. A goroutine starts with a stack of about 2KB that grows as needed, and the runtime multiplexes many goroutines onto a handful of OS threads. Starting thousands of them is normal. ...

October 11, 2026 路 8 min 路 1640 words 路 SpaghettiCoder