Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Executing go routines inside for loop with Boolean channels
package fragments
func downloadUrls(urls []string) {
done := make(chan bool, len(urls))
for _, url := range urls {
go func(url string) {
// perform download here
done <- true
// ensure all the routines are done
for i:=0; i<len(urls); i++ { <- done }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment