Curriculum Errors & packaging The error pattern exercise 2 · mcq
The error pattern
Pick the IDIOMATIC Go function signature for "load a User by
id, may fail" — the multi-return (T, error) convention that
every Go-shaped fallible operation uses.
TypeScript reaches for Promise<User> + reject paths or
User | null returns. Go's convention is positional:
result first, error second. The CALLER then checks the error
explicitly before using 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.