That one time I used Go panics for flow control

13 points by noncrab


olegkovalov

We have tried this solution but agreed on a separate goroutine for sorting (and a few other cpu intensive things).

  1. Compare func remains simple and does 1 thing
  2. We have somewhat better control on context lifetime
  3. Goroutinea are cheap
radio

Is this worth it? Maybe there is a cost to having those panic handlers there and panicking, and maybe the costs outweigh the costs of sorting?

minus

Reminder that http.Server uses panics for flow control (iirc something about aborting failed responses or so), which is important to know if you're writing panic-handling middleware