← Back to context

Comment by djha-skin

1 year ago

In Java you can set an uncaught exception handler, so you can make sure exceptions are caught in child threads from the parent.

In Go, defer blocks are only run for the panicking goroutine. Other goroutines do not run defer, the program simply crashes.

Sure, if the program crashes, all bets are off. That’s also true of any other similar exception mechanism.

The fact that the program crashes on unhandled panic, rather than letting you install a default global handler, is a design choice that has nothing to do with how goroutines are implemented.