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: x/sync: change errgroup to return a wrapped error instead of only the first #60415

Closed
fasmat opened this issue May 24, 2023 · 2 comments
Labels
Milestone

Comments

@fasmat
Copy link

fasmat commented May 24, 2023

golang.org/x/sync/errgroup returns the first non-nil error (if any) of all go routines managed by it. With the introduction of wrapped errors in go 1.20 this package could be updated to return a single error that wraps all errors returned by the routines started with it. The change would be minimal, essentially only replacing the errOncer with a mutex and errors.Join.

I am unsure if the change would breaking existing code using errgroup. At the moment users shouldn't rely on any specify error be returned, while with the change one can check if a specific error has occurred with errors.Is or errors.As.

@gopherbot gopherbot added this to the Proposal milestone May 24, 2023
@apparentlymart
Copy link

apparentlymart commented May 25, 2023

I raised a similar idea in the discussion of #57534 and the original author of errgroup responded that it's more appropriate to return only the error that causes the context to be cancelled.

That seems plausible to me so I didn't push that idea any further, but if you intend to pursue this proposal you may wish to consider that feedback and incorporate a response into your proposal.

@seankhliao
Copy link
Member

Duplicate of #23595

@seankhliao seankhliao marked this as a duplicate of #23595 May 25, 2023
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Incoming
Development

No branches or pull requests

4 participants