|
|
|
|
|
by alex_studer
1924 days ago
|
|
It looks like maybe the goroutine in that example doesn't actually get a chance to run before the program stops. If the main function lasts longer, then you'll see the effect of the panic. See https://goplay.tools/snippet/8SFlFkZ2P0y Also, see the Go spec: https://golang.org/ref/spec#Handling_panics > Next, any deferred functions run by F's caller are run, and so on up to any deferred by the top-level function in the executing goroutine. At that point, the program is terminated and the error condition is reported, including the value of the argument to panic. It looks like, assuming it makes it to the top of the current goroutine, then it should be killing the whole program. |
|
Personally I don't use panics or deal in them that much, mainly because stack traces with multiple goroutines are unbelievable. I much prefer errors.