golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.38k stars 17.59k forks source link

proposal: Go 2: Error-Handling Paradigm with !err Grammar Sugar #62253

Closed shynome closed 1 year ago

shynome commented 1 year ago

Hi, if you like this idea please give a heart emoji to me, Thank you very much

//  before, 4 line
f, err := os.Open()
if err != nil {
  return
}

// now, 1 line
f, !err := os.Open()

I plan to impl this by gone-lang, your like emoji can speed development

ianlancetaylor commented 1 year ago

Similar to #25273, #32500, #32884, #33074, #33150. See also #40432.

shynome commented 1 year ago

I think my proposal has the least broken

seankhliao commented 1 year ago

Duplicate of #14066

shynome commented 1 year ago

@seankhliao I don't know why you just because of they looks similar then close this, this has diffrence, this issue add limit for sugar so it easy to implement

ianlancetaylor commented 1 year ago

We have rejected many issues that are very similar, if not identical, to this one. Just as those were not accepted, we aren't going to accept this one. As I mentioned, please see #40432. Sorry.

shynome commented 1 year ago

so much proposal, can we make an vote to known which proposal is much popular? I really hate go error handle, so much template code

ianlancetaylor commented 1 year ago

Sorry, we don't make changes to the Go language on the basis of voting.

We are aware that error handling boilerplate is a concern. There have been many, many, proposals to address it. There has been an enormous amount of discussion on the topic.

shynome commented 1 year ago

here is my try: https://github.com/shynome/err4 .implement this by use code generate.

I'm so sorry for what I said. I didn't mean to hurt your feelings.

ianlancetaylor commented 1 year ago

No worries.

shynome commented 1 year ago

https://github.com/golang/go/issues/14066#issuecomment-173779313

I think the Proposal-Decline reason does not apply now, This year is 2023 not 2016, this year we have got generic type, a change bigger than this proposal, golang team can consider this again

ianlancetaylor commented 1 year ago

We've identified many similar issues. They have all been closed. This isn't an approach we are likely to take with Go. Sorry.