3 ms·
No, that's not possible. A panic must be recovered in the goroutine in which it occurs. An unrecovered panic in any goroutine kills the entire process, not just
by zachmu 6y ago
No, that's not possible. A panic must be recovered in the goroutine in which it occurs. An unrecovered panic in any goroutine kills the entire process, not just the offending goroutine. There is no way to top-down wrap an entire go process in a recover block to keep a panic from killing your process. You have to do it in each and every goroutine.
- joshuak 6y agoTrue, which is one of the reasons why the practice of launching goroutines inside of packages is discouraged. Granted its sometimes unavoidable and some package maintainers just didn't get the memo, nevertheless when deciding on a package to use it's much easer to find dubious goroutines, than assessing if every potential panic has been handled correctly. Usually easer to fix too if warranted.