package main import fmt net http sync func main var wg sync WaitGroup

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
package main
import (
"fmt"
"net/http"
"sync"
)
func main() {
var wg sync.WaitGroup
for i := 1; i <= 5; i++ {
wg.Add(1)
go func(url string) {
res, _ := http.Get(url)
fmt.Println(res)
wg.Done()
}("http://httpbin.org/get")
}
wg.Wait()
}