A critique of Go's error handling pattern, where every fallible call requires a 3-line `if err != nil` block that clutters the main logic flow. The author draws a comparison to assembly language, where a single conditional jump instruction (e.g., `jp nz, errorHandler`) achieves the same result in one line, allowing a single shared error handler for an entire procedure. The conclusion is that while Go's philosophy of returning errors rather than throwing exceptions is sound, the verbosity of its implementation makes code harder to read and more tedious to write.

4m read timeFrom drewdevault.com
Post cover image

Sort: