Created
October 23, 2017 15:06
-
-
Save krishna2nd/7c30b79a2ea9c022795f19b86a8ed875 to your computer and use it in GitHub Desktop.
Wait for group + routines Golang
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() { | |
var wg = sync.WaitGroup{} | |
for v := range []int{1, 2, 3, 4, 5, 6} { | |
wg.Add(1) | |
go (func(v int) { | |
fmt.Println(v) | |
wg.Done() | |
})(v) | |
} | |
wg.Wait() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment