Panic and recover

suggest change

This chapter assumes knowledge of defer.

In Go panic and recover are technically similar to exception handling in languages like C#, Java or Python.

panic is equivalent of throw or raise and recover fills the role of catch.

However, while those other languages often use exceptions as a way to propagate errors up the call chain, using panic in Go is highly discouraged.

It should only be used in truly exceptional cases.

For ordinary error handling, read chapter on error handling.

Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents