Created
March 14, 2016 13:45
-
-
Save ilyabrin/e4f5d22629bfa202f036 to your computer and use it in GitHub Desktop.
Bingo Network (raw)
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 "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