Go treats errors as ordinary values rather than exceptions. A function that can fail returns an error, and the caller decides what to do with it. This makes failure paths explicit and easy to follow, and it is one of the first things that makes Go code feel different.
This module starts with basic errors and the standard checking pattern. It then covers creating, wrapping and custom errors, how the errors package helps you inspect them, and finally defer, panic and recover, for the rare cases where a program cannot simply return an error.
Watch the lessons in order and practice by adding proper error checks to your own small programs, then continue on to Packages, Modules & Generics.
The starting point: how Go represents errors, how functions return them, and how to check them in your own code.
Creating errors with errors.New, wrapping them to add context, and defining your own custom error types.
A closer look at the standard errors package and the tools it provides for working with errors.
How defer, panic and recover work together, and when they are the right tool compared with returning an error.