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? https://go.dev/play/p/opTvk1x-uAm Specifically, the code calls runtime.Goexit <https://pkg.go.dev/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 -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/92ba1c4f-4c95-44f6-a2bb-a07c73c37481n%40googlegroups.com.
