草庐IT

scanLineWise

全部标签

stream - 如何从一个 io.Reader 获得多个消费者?

我正在编写一个小脚本,它使用bufio.Scanner和http.Request以及并行计算字数和行数的例程。packagemainimport("bufio""fmt""io""log""net/http""time")funcmain(){err:=request("http://www.google.com")iferr!=nil{log.Fatal(err)}//justkeepmainalivewithsleepfornowtime.Sleep(2*time.Second)}funcrequest(urlstring)error{res,err:=http.Get(url)i

stream - 如何从一个 io.Reader 获得多个消费者?

我正在编写一个小脚本,它使用bufio.Scanner和http.Request以及并行计算字数和行数的例程。packagemainimport("bufio""fmt""io""log""net/http""time")funcmain(){err:=request("http://www.google.com")iferr!=nil{log.Fatal(err)}//justkeepmainalivewithsleepfornowtime.Sleep(2*time.Second)}funcrequest(urlstring)error{res,err:=http.Get(url)i