Stage 1 · Lesson 6 of 10
Goroutines and channels
A is a function running at the same time as others, started with go f(). Goroutines are so cheap that you can run tens of thousands at once. The Go runtime spreads them over a few operating system , and puts any goroutine waiting on to one side.
A channel passes values between goroutines and keeps them in step. sync.WaitGroup waits for a group to finish, and sync.Mutex protects shared data. The net/http server already runs each request in its own goroutine, so you rarely start them in handlers.
Common trapa goroutine leak: a goroutine blocked forever on a channel nobody reads or writes. Before you start one, know how it ends and who closes each channel, and run tests with -race.
A question to check yourself, an AI practice session and 2 cheat sheet entries come with the full roadmap. Unlock
Resources for this stage
Start with
- CourseFreeA Tour of Go
The Go Authors · Beginner
The official interactive tour: basics, methods, interfaces, generics and concurrency
Practise
Keep handy
Also worth your time
The DNS, TCP, TLS and HTTP steps behind every request your backend will handle