In Go, we break down the difference between
panic and
error: which problems are considered “expected” and should be returned as errors, and which ones indicate a broken invariant and may justify a panic. Using a learning example of a CLI calculator, we will reinforce the
(T, error) contract, look at common runtime panics (slices,
nil map, division by zero), and discuss where the Must style fits.