Skip to content

Instantly share code, notes, and snippets.

@ostronom
Last active August 29, 2015 14:21
Show Gist options
  • Save ostronom/0b559ddc053bd079642f to your computer and use it in GitHub Desktop.
Save ostronom/0b559ddc053bd079642f to your computer and use it in GitHub Desktop.
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