tl;dr Why does Go choose not to exit cleanly when there are no more goroutines to run?
Background:
As part of a Go pub quiz, I asked the question:
What always happens when this code runs?
Specifically, the code calls
runtime.Goexit in the main goroutine. At termination, the program prints:
fatal error: no goroutines (main called runtime.Goexit) - deadlock!
Why is this considered a fatal error? Obviously there are no more goroutines to run, but why not exit cleanly in this case?
Obviously there's a very good reason for this behavior. I just can't work out what it is.
Any insights or ideas?
Regards,
Tom