Skip to main content

BLOG

Go from scratch, part 11: goroutines and the CSP model

Everything so far was the warm-up. Go concurrency is why the language exists and probably why you’re reading this series. And it starts with two letters: go. A goroutine is a function flying solo Put go in front of any call and that function runs concurrently, without blocking its launcher (A Tour of Go, goroutines): […]

READ MORE

Go from scratch, part 12: channels and select

Last article our goroutines flew solo and we waited for them with time.Sleep, which is like synchronizing watches by yelling out the window. Today the real tool arrives: Go channels, the typed pipes goroutines pass data through and, as a bonus, synchronize with. Channels: send, receive, block A channel is created with make and it’s […]

READ MORE

Go from scratch, part 14: sync, context, cancellation and timeouts

Channels are the preferred road, not the only one. Today we complete the toolbox with the sync package for classic synchronization and context, the standard mechanism for telling an army of goroutines the show is over. Getting Go context right is half of production readiness. sync.WaitGroup: waiting without sleeping The official replacement for those time.Sleep […]

READ MORE