We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e0938ad commit 6e51b77Copy full SHA for 6e51b77
go.mod
@@ -1,3 +1,3 @@
1
module github.com/pkg/group
2
3
-go 1.23
+go 1.25
group.go
@@ -52,9 +52,7 @@ func (g *G) init() {
52
// passed to it is canceled.
53
func (g *G) Add(fn func(context.Context) error) {
54
g.initOnce.Do(g.init)
55
- g.done.Add(1)
56
- go func() {
57
- defer g.done.Done()
+ g.done.Go(func() {
58
defer g.cancel()
59
defer func() {
60
if r := recover(); r != nil {
@@ -70,7 +68,7 @@ func (g *G) Add(fn func(context.Context) error) {
70
68
if err := fn(g.ctx); err != nil {
71
69
g.errOnce.Do(func() { g.err = err })
72
}
73
- }()
+ })
74
75
76
// wait waits for all goroutines in the group to exit. If any of the goroutines
0 commit comments