Using recover with goroutines
Understand how to apply recover in deferred functions to safely handle panics in Go goroutines. This lesson teaches you to stop failing goroutines cleanly while allowing other goroutines to continue running without disruption.
We'll cover the following...
We'll cover the following...
Recovering with goroutines
One application of recover is to shut down a failing goroutine inside a server without killing the other executing goroutines.
func server(workChan <-chan *Work) {
for work := range workChan {
go safelyDo(work) // start the goroutine ...