Last active
October 3, 2019 15:34
-
-
Save faruqisan/2af4f380dd8b648ca2ab60e1f75ea726 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 "sync" | |
func main() { | |
var wg sync.WaitGroup | |
urls := []string{"http://foo.com", "http://bar.com"} | |
for _, url := range urls { | |
wg.Add(1) | |
defer wg.Done() | |
go func(u string) { | |
err := fetchData(url) | |
if err != nil { | |
return err | |
} | |
}(url) | |
} | |
wg.Wait() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment