Go Error Propagation and API Contracts
I’ve been thinking about errors in Go quite a bit lately and what has been bothering me about the practice of error design and usage in the community. The critique starts with this code:
1 2 3 if err != nil { return err } It’s such a common piece of code that it has become a trope thanks to folks feeling like the apparent verbosity is an affront to their humanity. The verbosity’s not what I am going to be writing about today, nor is it something I have frankly ever given two shits about. What I care more about is the meaning of that code. Let’s contextualize that code again in func F:
matttproud.com (blog)