Curriculum Errors & packaging The error pattern exercise 3 · mcq
The error pattern
Exercise 2 pinned the (T, error) return convention. This exercise
pins the CALLER side — the idiomatic check-and-early-return
pattern that appears in every Go codebase, hundreds of times.
Pick the IDIOMATIC shape for "call a fallible function, bail
on error, otherwise use the result."
TypeScript reference
About this theme
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.