3 ms·
> As an example, with a goroutine you have to be careful to handle all errors, because a panic would take down the whole service. Unless you're the default `ne
by flakes 2y ago
> As an example, with a goroutine you have to be careful to handle all errors, because a panic would take down the whole service.
Unless you're the default `net/http` library and simply recover from the panic: https://github.com/golang/go/blob/master/src/net/http/server.go#L1944-L1949 https://github.com/golang/go/blob/master/src/net/http/server...
- neillyons 2y agoYou still need to be careful, as this won't catch panics from go routines launched from your http handler.
- ramchip 2y agoYeah, I'm simplifying a bit. It may not cause an immediate exit, but it can leave the service broken in unpredictable ways. See this discussion for instance: https://iximiuz.com/en/posts/go-http-handlers-panic-and-deadlocks/ https://iximiuz.com/en/posts/go-http-handlers-panic-and-dead...