14.6 The Main Goroutine and Program Termination
Right, let’s talk about the one goroutine you’ve been using all along without even knowing it: the main goroutine. It’s the VIP of your program, the first one on the scene, and frankly, a bit of a diva. When it decides to leave the party, the whole club shuts down immediately, regardless of how many other goroutines are still dancing on the tables. Think of your main() function as less of a function and more as a concert stage. When the program starts, the runtime sets up the stage and the main goroutine, our headliner, walks out and starts performing the code you wrote. This is its one and only job. It doesn’t get a special backstage pass or a different type of scheduler—it’s a goroutine like any other, just the first one.