Created
November 17, 2013 06:06
Revisions
-
inhies created this gist
Nov 17, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ package main import ( "fmt" "io/ioutil" "net/http" "os" "runtime" "sync" ) func init() { runtime.GOMAXPROCS(runtime.NumCPU()) } func main() { maxConncurrent := 100 var wg sync.WaitGroup urls := make(chan string, maxConncurrent) for i := 0; i < maxConncurrent; i++ { go func() { for url := range urls { resp, err := http.Get(url) if err != nil { fmt.Println(err) os.Exit(1) } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println(err) os.Exit(1) } if len(body) > 22609 { fmt.Println("FOUND:", url) } wg.Done() } }() } for i := 0; i < 10000; i++ { wg.Add(1) urls <- fmt.Sprintf("http://dawnofthedeaddash.com/mobile/?code=%d", i) } wg.Wait() fmt.Println("Finished") }