Go Error Handling

Discussions debate the pros and cons of Go's explicit error handling via return values, criticizing its verbosity and repetitiveness while defenders praise its reliability and explicitness compared to exceptions in other languages.

➡️ Stable 0.6x Programming Languages
4,633
Comments
19
Years Active
5
Top Authors
#3922
Topic ID

Activity Over Time

2008
1
2009
11
2010
14
2011
30
2012
175
2013
157
2014
226
2015
180
2016
212
2017
297
2018
246
2019
386
2020
296
2021
393
2022
466
2023
477
2024
550
2025
476
2026
40

Keywords

CopyFile COM e.g EOF io.Read L11 NO JavaScript AND os.Open error error handling errors handling err nil return exceptions func code

Sample Comments

TheDong Jan 13, 2015 View on HN

That sounds incredibly ignorant to me.If this is the first language you've used where you give that sort of attention to errors, you must not have used and learned from the terrible mistakes of C, which constantly returns errors which are not required to be handled, just like go.Heck, you must not have learned from bash where every second line is "if [[ $? != 0 ]]" or you just did set -e and fail hard.For me, the problem with Go's errors isn't even the lines the

meddlepal Mar 13, 2020 View on HN

Nope. Error handling in Go is still tedious.

Zababa Dec 15, 2021 View on HN

I'm not sure error handling in Go is really explicit. Go checks that you assign an error and usually handle it, but it doesn't check that you handle all values of the error. If a function suddenly returns a new error value, the compiler won't help you here. This is like in language with unchecked exceptions, you have to read everything carefully.

richardwhiuk Jul 12, 2021 View on HN

I agree - I find Go's error handling encourages subtle bugs.

weberc2 Aug 19, 2017 View on HN

Go has error handling, it doesn't have exceptions for non-exceptional error cases.

dhconnelly Jul 24, 2012 View on HN

Go doesn't "lack error-handling." They're referring to the fact that Go doesn't have exceptions; you check return codes to detect and handle errors. For some this is tedious, but has advantages (mentioned in the article) with respect to understanding an entire program.

dnautics Aug 13, 2021 View on HN

returning errors doesn't have to have cluttered code. Just because Go messed it up doesn't mean it's bad.

PufPufPuf Apr 12, 2025 View on HN

By "error handling" in Go you mean "if err == nil" repeating every five lines throughout the codebase?

qtplatypus Jul 17, 2019 View on HN

I am a full time developer in go. I feel the lack of good error handling every time I write a function call and then have to use the same if statement to check its result.

erik_seaberg Nov 1, 2020 View on HN

Go calls it "errors are values", but readability is poor when every error must be handled many times instead of implicitly returning to callers.