Very slow perfomance with multiple http.Get (Windows 7).
Some urls is not exists and it looks like something blocking.
Please, help.
package main
import (
"fmt"
"io/ioutil"
"net/http"
"runtime"
"strings"
"time"
)
func goroutine(task string) {
_, err := http.Get(task)
if err != nil { fmt.Print("-") } else { fmt.Print("+") }
}
func main() {
// use all available processors
runtime.GOMAXPROCS(runtime.NumCPU())
// read file with strings (urls)
f_byte, err := ioutil.ReadFile("u.txt")
if err != nil {
fmt.Println(err)
return
}
f_string := strings.Replace(string(f_byte), "\r\n", "\n", -1)
f_strings := strings.Split(f_string, "\n")
// run goroutines
for i := range f_strings {
go goroutine(f_strings[i])
}
time.Sleep(60 * time.Second)
}
--