Handling Errors in Go

Understand how to create and use errors in Go.

Many of us come from languages that handle errors using exceptions. Go takes a different approach, treating errors like our other data types. This prevents common problems that exception-based models have, such as exceptions escaping up the stack.

Go has a built-in error type called error. It is based on the interface type, with the following definition:

Get hands-on with 1400+ tech skills courses.