-
-
Save ostronom/0b559ddc053bd079642f to your computer and use it in GitHub Desktop.
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 ( | |
"net/http" | |
) | |
func doRequests(url string, num uint16) { | |
ch := make(chan bool, num) | |
var i uint16 = 0 | |
for ; i < num; i++ { | |
go func() { | |
http.Get(url) | |
ch <- true | |
}() | |
} | |
var resps = num | |
for { | |
select { | |
case <- ch: | |
resps-- | |
if resps == 0 { return } | |
} | |
} | |
} | |
func main() { | |
doRequests("http://google.com", 300) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment