Skip to content

Instantly share code, notes, and snippets.

@ilyabrin
Created March 14, 2016 13:45
Show Gist options
  • Select an option

  • Save ilyabrin/e4f5d22629bfa202f036 to your computer and use it in GitHub Desktop.

Select an option

Save ilyabrin/e4f5d22629bfa202f036 to your computer and use it in GitHub Desktop.
Bingo Network (raw)
package main
import "net/http"
type response struct {
resp *http.Response
url string
}
func get(url string, r chan response) {
if resp, err := http.Get(url); err == nil {
r <- response{resp, url}
}
}
func main() {
first := make(chan response)
for _, url := range []string{
"http://127.0.0.1/proxy/1",
"http://127.0.0.1/proxy/2",
"http://127.0.0.1/proxy/3"} {
go get(url, first)
}
r := <-first
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment