logoalt Hacker News

Mond_last Tuesday at 6:31 PM5 repliesview on HN

I really don't like how this article claims that the primary issue with Go's error handling is that the syntax is too verbose. I don't really care about that.

How about:

- Errors can be dropped silently or accidentally ignored

- function call results cannot be stored or passed around easily due to not being values

- errors.Is being necessary and the whole thing with 'nested' errors being a strange runtime thing that interacts poorly with the type system

- switching on errors being hard

- usage of sentinel values in the standard library

- poor interactions with generics making packages such as errgroup necessary

Did I miss anything?


Replies

closeparenlast Tuesday at 11:21 PM

90% of working professionally in Go is contriving test cases to achieve statement coverage over each error return branch, something no one would ever do in a language with exceptions.

show 2 replies
neildlast Tuesday at 7:36 PM

> I really don't like how this article claims that the primary issue with Go's error handling is that the syntax is too verbose.

I don't believe this claim is made anywhere.

We've decided that we are not going to make any further attempts to change the syntax of error handling in the foreseeable future. That frees up attention to consider other issues (with errors or otherwise).

show 1 reply
GiorgioGlast Tuesday at 6:34 PM

Just remember it took FOREVER for Go to support some form of generics. Go evolution happens at a glacial pace. That's a feature, not a bug....to many.

VirusNewbielast Tuesday at 7:38 PM

Agreed, 100%.

We're both Googlers here and this is so disappointing to be let down again by the Go team.

SkepticalWhalelast Wednesday at 4:18 PM

I agree with item #1, but it can be mitigated somewhat with dev tools like errcheck: https://github.com/kisielk/errcheck?tab=readme-ov-file