Skip to content

Commit

Permalink
Update waitgroups example to use go 1.22 (#508)
Browse files Browse the repository at this point in the history
gorutine closures inside for loops does not require variable
reassignment since the 1.22 for loop changes
  • Loading branch information
pzerone committed Feb 9, 2024
1 parent 5aa9ad7 commit a3fb3a3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 21 deletions.
4 changes: 0 additions & 4 deletions examples/waitgroups/waitgroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ func main() {
// counter for each.
for i := 1; i <= 5; i++ {
wg.Add(1)
// Avoid re-use of the same `i` value in each goroutine closure.
// See [the FAQ](https://golang.org/doc/faq#closures_and_goroutines)
// for more details.
i := i

// Wrap the worker call in a closure that makes sure to tell
// the WaitGroup that this worker is done. This way the worker
Expand Down
4 changes: 2 additions & 2 deletions examples/waitgroups/waitgroups.hash
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
66d1c1cdb7e60f63b9b30938aa9c63b2262463ac
S98GjeaGBX0
c81a54fed0cd96464456e05b46163329eb7c958b
fC_Chrkb5uA
17 changes: 2 additions & 15 deletions public/waitgroups

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a3fb3a3

Please sign in to comment.