diff --git a/src/goroutine-exit.md b/src/goroutine-exit.md index 6cc5b42..9cffb91 100644 --- a/src/goroutine-exit.md +++ b/src/goroutine-exit.md @@ -4,17 +4,13 @@ Given a goroutine spawned by the system, there must be a way to wait for the goroutine to exit. There are two popular ways to do this: -- Use a `sync.WaitGroup`. - Do this if there are multiple goroutines that you want to wait for +- Use a `sync.WaitGroup` to wait for multiple goroutines to complete. + Do this if there are multiple goroutines that you want to wait for. ```go var wg sync.WaitGroup for i := 0; i < N; i++ { - wg.Add(1) - go func() { - defer wg.Done() - // ... - }() + wg.Go(...) } // To wait for all to finish: diff --git a/style.md b/style.md index bf0d20b..6ffaff4 100644 --- a/style.md +++ b/style.md @@ -2039,17 +2039,13 @@ Given a goroutine spawned by the system, there must be a way to wait for the goroutine to exit. There are two popular ways to do this: -- Use a `sync.WaitGroup`. - Do this if there are multiple goroutines that you want to wait for +- Use a `sync.WaitGroup` to wait for multiple goroutines to complete. + Do this if there are multiple goroutines that you want to wait for. ```go var wg sync.WaitGroup for i := 0; i < N; i++ { - wg.Add(1) - go func() { - defer wg.Done() - // ... - }() + wg.Go(...) } // To wait for all to finish: