Skip to content

Commit 6e51b77

Browse files
committed
update go.mod to use Go 1.25 and refactor goroutine handling in Add method
1 parent e0938ad commit 6e51b77

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module github.com/pkg/group
22

3-
go 1.23
3+
go 1.25

group.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ func (g *G) init() {
5252
// passed to it is canceled.
5353
func (g *G) Add(fn func(context.Context) error) {
5454
g.initOnce.Do(g.init)
55-
g.done.Add(1)
56-
go func() {
57-
defer g.done.Done()
55+
g.done.Go(func() {
5856
defer g.cancel()
5957
defer func() {
6058
if r := recover(); r != nil {
@@ -70,7 +68,7 @@ func (g *G) Add(fn func(context.Context) error) {
7068
if err := fn(g.ctx); err != nil {
7169
g.errOnce.Do(func() { g.err = err })
7270
}
73-
}()
71+
})
7472
}
7573

7674
// wait waits for all goroutines in the group to exit. If any of the goroutines

0 commit comments

Comments
 (0)