When is v2 draft design reality especially for error handling

Hi dear community,

So as many of you know, lots of situations gets you into verbose and reperative statements like

if err != nil { return err} 

for further propagation from your function that has some identical signature like:

func(...) error

When reading the draft Error Handling — Draft Design , there have been many efforts to introduce a keyword into the language that somehow simplifies and erases the repatativity and verboseness those situations can get.

For example Zig’s try is nice and Rust’s “The ? Operator Shortcut<Result>?.

Those are great examples, more than 5 years have passed since the initial of this draft, design and i get it, introducing new keywords and manners to the language is difficult I got it, I wouldn’t also be able to understand it as I have never build or designed any language, but can someone explain why this is taking so long?

Go is also generally designed for simplicity and teams, easy code base, but those situations can make if err ; return err very repetitive annoying and your code ugly. When comes this fix that solves this? It doesn’t look like crazy rocket science and it can be backward compatible so when will we see it?? The feature asked seems like it can be implemented with backward compatibility in mind, something the Go team strictly adheres to.

Go was a language I learnt to get more low-level although Go is a high-level language, situations can get you more into low-level stuff compared to Typescript. After Go I read the Rust book and after completing it, I went over to the Rust async book which generally gives teachings of how OS’s implement async behind the scenes and how it works. I then made some crates and been very comfortable with Rust too.

I really like Go and Rust alot, but Rust is multi-paradigmatic, making me wanting to have expressiveness in Go as well but sometimes I am limited be the lack of modern keywords or language patterns. However that is good, Go has to stay simple, but the lack of try or Rust’s ? for error handling or such amazes me…

I don’t believe this will ever be adopted. There have been many proposals over the years, but I don’t think anybody will ever agree on a new approach. See this recent issue created by Ian Lance Taylor:

Note the number of downvotes. And see subsequent discussion:

It is, more or less, because most gophers don’t want this change. I participated in the discussion on this and people are pretty set in their ways it would seem. For better or worse.

Hi, thanks for your response.

Even if the majority doesn’t want it, it looks like a handy new keyword if it existed when it has backward compatibility. It’s up to the programmer whether they use for example the try keyword or verbose and repetitive returns statements.

Currently I am mostly using Rust cuz it is an amazing language and so expressive. I just only use Go when I wanna make something fast, Go has an amazing development speed and it’s still pretty performant on the runtime for most common cases

Propably final statement.

And I do say that I agree with them. :+1:

Furthermore I personally don’t have those

if err != nil { return err}

so much, because if you do this you have to decide what to do then?!
Do you have a condition switch in the parent function?

It is better to handle the error right in place. I mean at least you want to have a log on what failed?