Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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



I'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...


I’m honored you disagree with me enough to write your thoughts on the matter. Thank you for your insight.


Can't tell if it's sarcasm or not


No, I'm not being sarcastic. It's easier to ignore a comment than it is to discuss the topic.


Well, 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




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: