Curriculum Errors & packaging The error pattern
The error pattern
Go has no exceptions for ordinary control flow. Errors are values returned alongside results — (T, error). The caller checks err != nil and decides. This feels noisy at first; it becomes legible once you trust the convention. fmt.Errorf("... %w", err) wraps, preserving the inner error.
Exercises
9 ready
01
pick one
Go has no exceptions. The error BUILT-IN INTERFACE is the
02
pick one
Pick the IDIOMATIC Go function signature for "load a User by
03
pick one
Exercise 2 pinned the (T, error) return convention. This exercise
04
fill blanks
Type the stdlib PACKAGE NAME you import for errors.New,
05
fill blanks
Return the "no error" sentinel from the success path. Type
06
type one line
Construct a new error with a string message. errors.New is
07
type one line
The if-init form of error handling — declare + check in one
08
write a program
Write a complete program with divide(a, b int) (int, error)
09
write a program
Theme 5.1 capstone — ERROR WRAPPING with fmt.Errorf %w