package main
import (
"fmt"
"net/http"
"sync"
"time"
)
var wg sync.WaitGroup
func getResp() {
defer wg.Done()
res, err := http.Get("http://ya.ru")
if err != nil {
fmt.Println(err)
} else {
fmt.Println(res.Status)
}
}
func main() {
start := time.Now()
for i := 0; i < 10; i++ {
wg.Add(1)
go getResp()
}
wg.Wait()
elapsed := time.Since(start)
fmt.Println("Время выполнения ", elapsed)
}
dirs, err := ioutil.ReadDir(config.ProjectDir)
if err != nil {
log.Fatal(err)
}
for _, dir := range dirs {
fmt.Print(dir.Name())
}
url := "http://ajax.googleapis.com/ajax/services/search/images?v=1.0&imgsz=large&rsz=8&q="
response, err := http.Get(url)
if err != nil {
log.Fatal(err)
}
fmt.Println(response.StatusCode)
defer response.Body.Close()
data, err := ioutil.ReadAll(response.Body)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(data))