MCPcopy Index your code
hub / github.com/sourcegraph/conc / ExampleErrorPool

Function ExampleErrorPool

pool/error_pool_test.go:14–29  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

12)
13
14func ExampleErrorPool() {
15 p := New().WithErrors()
16 for i := 0; i < 3; i++ {
17 i := i
18 p.Go(func() error {
19 if i == 2 {
20 return errors.New("oh no!")
21 }
22 return nil
23 })
24 }
25 err := p.Wait()
26 fmt.Println(err)
27 // Output:
28 // oh no!
29}
30
31func TestErrorPool(t *testing.T) {
32 t.Parallel()

Callers

nothing calls this directly

Calls 4

NewFunction · 0.70
WithErrorsMethod · 0.45
GoMethod · 0.45
WaitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…