Codebase list golang-github-vbauerster-mpb / 2369fd7
fix ExampleBar_ProxyReader Vladimir Bauer 8 years ago
1 changed file(s) with 4 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
11
22 import (
33 "io"
4 "io/ioutil"
45 "math/rand"
56 "net/http"
67 "time"
6162
6263 func ExampleBar_ProxyReader() {
6364 p := mpb.New()
64 // make http get request
65 resp, err := http.Get(url)
66 if err != nil {
67 return err
68 }
65 // make http get request, ignoring errors
66 resp, _ := http.Get("https://homebrew.bintray.com/bottles/libtiff-4.0.7.sierra.bottle.tar.gz")
6967 defer resp.Body.Close()
7068
7169 // Assuming ContentLength > 0
7977 reader := bar.ProxyReader(resp.Body)
8078
8179 // and copy from reader, ignoring errors
82 io.Copy(dest, reader)
80 io.Copy(ioutil.Discard, reader)
8381
8482 p.Wait()
8583 }