Loading…
40+ curated questions with the same answer shape every time: quick recap, deep dive, pitfalls, and follow-ups. Coverage includes error interface, errors new, multiple return error, if err not nil pattern, and more.
Suggested path
Topics follow a teaching order. Each answer ends with a clear Next question control so you can move forward without hunting the list.
Go error handling is explicit by design — there is no try/catch, no exceptions, and errors are values that flow through the program like any other return value. This module introduces the error interface (one method: Error() string), creating errors with errors.New and fmt.Errorf, the ubiquitous (value, error) return pattern and the if err != nil idiom, wrapping errors with the %w verb in fmt.Errorf (Go 1.13+), creating custom error types by implementing the error interface, and the critical distinction between panic (for programmer errors and truly unrecoverable states) and the error return value (for expected error conditions like 'file not found' or 'user not found'). The comparison question is always 'why doesn't Go have exceptions?' and this module gives the answer Go's designers intended: explicit error handling makes error paths visible, forces callers to handle them, and makes code easier to reason about.
Full catalog
Topics are ordered for learning. Within each topic, rows are numbered 1–40 globally so you always know where you are. Collapse topics if you want a lighter view — use Expand all when you need the full list again.
Numbers 1–40 follow the order we recommend — click any row to open the full answer, or use the sticky Next link at the bottom of each page to go Q1 → Q40.