Skip to content

Commit

Permalink
Fixed bug in WaitGroup example (#1809)
Browse files Browse the repository at this point in the history
  • Loading branch information
deefstes authored Apr 4, 2022
1 parent 03a1464 commit 5a312cd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions go.md
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ func main() {
for _, item := range itemList {
// Increment WaitGroup Counter
wg.Add(1)
go doOperation(item)
go doOperation(&wg, item)
}
// Wait for goroutines to finish
wg.Wait()
Expand All @@ -441,7 +441,7 @@ func main() {
{: data-line="1,4,8,12"}

```go
func doOperation(item string) {
func doOperation(wg *sync.WaitGroup, item string) {
defer wg.Done()
// do operation on item
// ...
Expand Down

0 comments on commit 5a312cd

Please sign in to comment.