GO LEARNING PATH · 6 LESSONS
Errors
Wrapping, errors.Is and errors.As, sentinels, defer and the panic boundary.
%w adds context without hiding the cause
Wrap an error so callers can still match the original.
3 min · Worked lesson
Is compares, As extracts
Choose between errors.Is and errors.As without trial and error.
3 min · Worked lesson
defer runs last in, first out
Release what you acquired, in the right order, on every path.
3 min · Prediction challenge
An error is any type with an Error method
Write an error that carries data the caller can read.
3 min · Worked lesson
panic is for bugs, not for failures
Say which of two situations deserves a panic.
3 min · Prediction challenge
recover belongs at the boundary
Turn a panic into an error without swallowing the rest of the program.
3 min · Worked lesson