Last active
April 9, 2023 07:48
-
-
Save dumindu/80a9e888d55afdf7a1d0f75566f41589 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"sync" | |
) | |
func main() { | |
items := []int{0, 1, 2, 3, 4, 5, 6, 7, 8, 9} | |
wg := sync.WaitGroup{} | |
wg.Add(len(items)) | |
for _, item := range items { | |
go func(i int) { | |
fmt.Println(i) | |
wg.Done() | |
}(item) | |
} | |
wg.Wait() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment