4 ms·
No, Go didn't get this right. Returning a tuple (a T and an errror) isn't an appropriate tool when you want your function to return either a T or an errror. It'
by Expurple 1y ago
No, Go didn't get this right. Returning a tuple (a T and an errror) isn't an appropriate tool when you want your function to return either a T or an errror. It's a brittle hack that reqires everyone to use a third-party linter on top. Otherwise that tuple is handled incorrectly too frequently.
All of that, because Go keeps ignoring a basic feature from the 1970s [1] that allows to you express the "or" relationships (and nullability).
APIs that are easy to use incorrectly are bad APIs.
[1]: https://en.wikipedia.org/wiki/Tagged_union#1970s_&_1980s https://en.wikipedia.org/wiki/Tagged_union#1970s_&_1980s
- Expurple 1y agoI've even decided to turn my parent comment into a blog post [1]. It also fixes numerous typos, so qoute the blog version. [1] https://home.expurple.me/posts/go-did-not-get-error-handling-right/ https://home.expurple.me/posts/go-did-not-get-error-handling...
- andrewmcwatters 1y agoI’m honored you disagree with me enough to write your thoughts on the matter. Thank you for your insight.
- Expurple 1y agoCan't tell if it's sarcasm or not
- andrewmcwatters 1y agoNo, I'm not being sarcastic. It's easier to ignore a comment than it is to discuss the topic.
- Expurple 1y agoWell, I just have an intrinsic interest in discussing this topic deeply and understanding it deeply. So far, all of my technical posts on the blog have been about error handling