Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: errors/result: #54589

Closed
MikhailBatsin-code opened this issue Aug 22, 2022 · 2 comments
Closed

proposal: errors/result: #54589

MikhailBatsin-code opened this issue Aug 22, 2022 · 2 comments

Comments

@MikhailBatsin-code
Copy link

Add a "Result" structure for handling errors like in rust or make it built-in.

why?

Lots of people consider go-way error handling very annoying and inconvenient, so there must be something that will make error handling in go better.

Solution(for full implementation check out my repository)

make a Result struct:

type Result[T any] struct {
    // must be private
    ok T
    err error
}
@gopherbot gopherbot added this to the Proposal milestone Aug 22, 2022
@mvdan
Copy link
Member

mvdan commented Aug 22, 2022

Please note that you should fill https://github.com/golang/proposal/blob/master/go2-language-changes.md when proposing a language change.

I realise this is technically not a language change, but if you are trying to change many func signatures from (T, error) to errors.Result[T], that is a large and breaking change that will affect the vast majority of Go code out there today.

@seankhliao
Copy link
Member

Duplicate of #51931

@seankhliao seankhliao marked this as a duplicate of #51931 Aug 22, 2022
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Aug 22, 2022
@golang golang locked and limited conversation to collaborators Aug 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants