Home » Go Recover

Go Recover

Recover is used to regain control of a program from panic or error-condition. It stops the terminating sequence and resumes the normal execution. It is called from the deferred function. It retrieves the error value passed through the call of panic. Normally, it returns nil which has no other effect.

Go recover() Example

Output:

runtime error: integer divide by zero 0 <nil> 1 

Next TopicGo Defer

You may also like