Created
October 4, 2016 12:17
-
-
Save afrikaan-official/47dfd67d7da3ccb0905aa0b260d4b797 to your computer and use it in GitHub Desktop.
sample sync package in go
This file contains 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" | |
"net/http" | |
"time" | |
"sync" | |
) | |
var wg=sync.WaitGroup{} | |
func main() { | |
t:=time.Now() | |
var sites =[3]string{"http://oley.com","http://bilyoner.com","http://nesine.com"} | |
for _,v:= range sites{ | |
go func(url string){ | |
wg.Add(1) | |
defer wg.Done() | |
r,_:=http.Get(v) | |
defer r.Body.Close() | |
fmt.Println(r.Status) | |
}(v) | |
} | |
wg.Wait() | |
fmt.Println(time.Since(t).String()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment