← Course map

GO LEARNING PATH · 6 LESSONS

Errors

Wrapping, errors.Is and errors.As, sentinels, defer and the panic boundary.

  1. %w adds context without hiding the cause

    Wrap an error so callers can still match the original.

    3 min · Worked lesson

  2. Is compares, As extracts

    Choose between errors.Is and errors.As without trial and error.

    3 min · Worked lesson

  3. defer runs last in, first out

    Release what you acquired, in the right order, on every path.

    3 min · Prediction challenge

  4. An error is any type with an Error method

    Write an error that carries data the caller can read.

    3 min · Worked lesson

  5. panic is for bugs, not for failures

    Say which of two situations deserves a panic.

    3 min · Prediction challenge

  6. recover belongs at the boundary

    Turn a panic into an error without swallowing the rest of the program.

    3 min · Worked lesson