From 69efd4b8c091af10203ad9914e260a6fa9b7bc34 Mon Sep 17 00:00:00 2001 From: Eli Bendersky Date: Mon, 30 Aug 2021 09:18:16 -0700 Subject: [PATCH] Add note to waitgroups example about errgroup Fixes #308 --- examples/waitgroups/waitgroups.go | 5 +++++ examples/waitgroups/waitgroups.hash | 4 ++-- public/waitgroups | 21 ++++++++++++++++++--- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/examples/waitgroups/waitgroups.go b/examples/waitgroups/waitgroups.go index c3c8580..9e045d4 100644 --- a/examples/waitgroups/waitgroups.go +++ b/examples/waitgroups/waitgroups.go @@ -39,4 +39,9 @@ func main() { // Block until the WaitGroup counter goes back to 0; // all the workers notified they're done. wg.Wait() + + // Note that this approach has no straightforward way + // to propagate errors from workers. For more + // advanced use cases, consider using the + // [errgroup package](https://pkg.go.dev/golang.org/x/sync/errgroup). } diff --git a/examples/waitgroups/waitgroups.hash b/examples/waitgroups/waitgroups.hash index ab9311b..2de67d2 100644 --- a/examples/waitgroups/waitgroups.hash +++ b/examples/waitgroups/waitgroups.hash @@ -1,2 +1,2 @@ -fd77f5122e6df1669c0a2e0d2c4dfbd30631c21f -7mWXl0yVe6I +b87ababcf7e1ce54107252c658840097bb6060a7 +vXBl8zQpDYj diff --git a/public/waitgroups b/public/waitgroups index 2fc1a33..21feb59 100644 --- a/public/waitgroups +++ b/public/waitgroups @@ -42,7 +42,7 @@ use a wait group.

- +
package main
 
@@ -165,10 +165,25 @@ counter for each.

all the workers notified they’re done.

- +
     wg.Wait()
+
+ + + + + +

Note that this approach has no straightforward way +to propagate errors from workers. For more +advanced use cases, consider using the +errgroup package.

+ + + + +
 }
 
@@ -223,7 +238,7 @@ is likely to be different for each invocation.