...

/

Recover

Recover

This lesson is a guide for programmers to recover their code from panic or any error condition.

We'll cover the following...

What is recover() function?

As the name indicates, this built-in function can be used to recover from a panic or an error-condition: it allows a program to regain control of a panicking Go routine, stopping the terminating sequence and resuming normal execution. The recover is only useful when called inside a deferred function: it then retrieves the error value passed through the call to panic. When used in normal execution, a call to recover will return nil and have no ...