Skip to content

Instantly share code, notes, and snippets.

@krishna2nd
Created October 23, 2017 15:06
Show Gist options
  • Save krishna2nd/7c30b79a2ea9c022795f19b86a8ed875 to your computer and use it in GitHub Desktop.
Save krishna2nd/7c30b79a2ea9c022795f19b86a8ed875 to your computer and use it in GitHub Desktop.
Wait for group + routines Golang
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