top | item 43261208

(no title)

enjoylife | 1 year ago

Only at the very end does the article call out there is actually a performance aspect if you use panic and recover as intended.

> So it seems that panic and recover can be beneficial to performance in at least some situations.

Namely top level & centralized recovery handling. I'll also point out its important your panic recovery must happen in a deferred function if your kicking off new goroutines. For example, your server library probably has default panic recovery on the goroutines handling inbound requests, but any new goroutines you create as part of handling the request (e.g. to parallelize work), will not have this handling built in. See https://go.dev/blog/defer-panic-and-recover for more.

discuss

order

No comments yet.