Module 05 Β· Goroutines & Channels β Lesson 1 of 3 Β· ~12 min
Goroutines
The reason Go runs servers
A PawWalk server is never doing one thing. While it answers the walker-list request for one phone, it is also streaming GPS fixes to a client watching a live walk, charging a card, and accepting a brand-new booking β all at the same instant. A backend's whole job is many things at once.
Go's answer is the goroutine: a function that runs concurrently with everything else. You launch one by putting the word go in front of a call. That's the entire syntax.
A goroutine is not an OS thread. Go multiplexes thousands of them onto a handful of real threads, so starting one costs about 2 KB of stack. Spinning up 10,000 goroutines is normal; spinning up 10,000 threads would melt the machine.