()
| 9 | ) |
| 10 | |
| 11 | func ExampleWaitGroup() { |
| 12 | var count atomic.Int64 |
| 13 | |
| 14 | var wg WaitGroup |
| 15 | for i := 0; i < 10; i++ { |
| 16 | wg.Go(func() { |
| 17 | count.Add(1) |
| 18 | }) |
| 19 | } |
| 20 | wg.Wait() |
| 21 | |
| 22 | fmt.Println(count.Load()) |
| 23 | // Output: |
| 24 | // 10 |
| 25 | } |
| 26 | |
| 27 | func ExampleWaitGroup_WaitAndRecover() { |
| 28 | var wg WaitGroup |