27
// exit on their own (possibly never).
28
// NOTE: Errors returned by the supplied function are ignored.
30
>
g.initOnce.Do(g.init)
31
>
g.wg.Go(func() {
32
>
_ = f(g.ctx)
33
>
})
34
}
35
36
// Cancel cancels the `context.Context` that was passed to all goroutines
37
// spawned via `Go` on this `Group`.
39
>
g.initOnce.Do(g.init)
40
>
g.cancel()
41
>
}
42
43
// Wait blocks waiting for all goroutines spawned via `Go` on this `Group`
44
// instance to complete. If `Go` has not been called then this function returns
45
// immediately.
47
>
g.wg.Wait()
48
>
}
49
51
>
g.ctx, g.cancel = context.WithCancel(context.Background())
52
>
}