You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BTW, the way how code currently does "appending" is really ... bad. I think. As an author of one of (I believe) good errors packages for Go the issue with current approach is that you create a tree of joined errors. Every time you call errors.Join it creates a new error with two child errors.
A better way I think would be to have a slice of errors you append to and join just once at the end (you could even join in defer and set a named return value. errors.Join also discards all nil errors, so you could just be collecting all errors without checking (unless it influences the code flow). I did something similar here. Maybe the best way would be to extract inner loop code to sendOne internal function which returns error as usual. And then you collect errors in the loop and call final errors.Join.
BTW, the way how code currently does "appending" is really ... bad. I think. As an author of one of (I believe) good errors packages for Go the issue with current approach is that you create a tree of joined errors. Every time you call
errors.Join
it creates a new error with two child errors.A better way I think would be to have a slice of errors you append to and join just once at the end (you could even join in
defer
and set a named return value.errors.Join
also discards all nil errors, so you could just be collecting all errors without checking (unless it influences the code flow). I did something similar here. Maybe the best way would be to extract inner loop code tosendOne
internal function which returns error as usual. And then you collect errors in the loop and call finalerrors.Join
.Originally posted by @mitar in #166 (comment)
The text was updated successfully, but these errors were encountered: