Thank you for helping me.The other question is: if I only change fetch
function,how to make the same result??
在 2017年11月13日星期一 UTC+8下午9:08:00,Ayan George写道:
>
>
>
> On 11/13/2017 04:10 AM, 28911...@gmail.com wrote:
>
> > for range os.Args[1:] {
> > fmt.Println(<-ch)
> > }
On 11/13/2017 04:10 AM, 2891132l...@gmail.com wrote:
> for range os.Args[1:] {
> fmt.Println(<-ch)
> }
> fmt.Printf("%.2fs elasped\n", time.Since(start).Seconds())
> }
If I understand correctly, you want fetch() to get each URL twice but
you only read from the 'ch' chann
I try writing the program and run it. the program is as following:
package main
import (
"fmt"
"io"
"io/ioutil"
"net/http"
"os"
"time"
)
func main() {
start := time.Now()
ch := make(chan string)
for _, url := range os.Args[1:] {
go fetch(url, ch)