Repository navigation
The same three functions, now generic. See MIGRATION.md for the before and after of every call.
Added
- A type parameter on
AsyncFunc,Race,AllandRetry: results come back typed, with no type assertions. - Runnable examples in
examples/, each with a test: racing mirrors, checking URLs at once, retrying with backoff.
Changed
- Module path is
github.com/vardius/gollback/v2; Go 1.26 or newer is required. Racereturns every error, joined in the order of the functions, when they all fail.Racereturns ctx's error joined with the errors of the functions that had failed when ctx is done first,
and calls no function when ctx is done before the call.Retryreturns ctx's error joined with the function's last error when ctx is done first.- A function that calls
runtime.Goexit, ast.FailNowdoes, counts as failed inRace, and inAll
for every function but the first, which runs on the calling goroutine. - A failed call's result is dropped:
RaceandRetryreturn the zero value with an error,
andAllleavesresults[i]zero whenerrs[i]is set. Allruns the first function on the calling goroutine.- Faster, with fewer allocations. Racing one function went from 762 ns and 13 allocations to 348 ns and 5;
Allof one function from 285 ns to 15 ns;Retryfrom 25 ns to 13 ns, still allocating nothing.
Allocation counts are guarded by tests.
Removed
- The nil-context check and its "nil context provided" panic.