← Go Programming learning pathGo Programming · Module 8 of 10
Goroutines and channels
Run concurrent work safely.
📖 Key ideas
- go doWork() starts a goroutine.
- Channels pass values between goroutines: ch := make(chan int).
- Send ch <- v; receive v := <-ch.
- sync.WaitGroup waits for goroutines; sync.Mutex protects shared data.
- select waits on multiple channels.
💡 Real-life example: Goroutines are workers; channels are conveyor belts passing items between them.
goroutineLightweight thread
channelTyped pipe between goroutines
WaitGroupWaits for goroutines to finish
selectWaits on multiple channel operations