forked from vbauerster/mpb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
41 lines (33 loc) · 783 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package main
import (
"crypto/rand"
"io"
"io/ioutil"
"time"
"github.com/mikewiacek/mpb"
"github.com/mikewiacek/mpb/decor"
)
func main() {
var total int64 = 1024 * 1024 * 500
reader := io.LimitReader(rand.Reader, total)
p := mpb.New(
mpb.WithWidth(60),
mpb.WithRefreshRate(180*time.Millisecond),
)
bar := p.AddBar(total, mpb.BarStyle("[=>-|"),
mpb.PrependDecorators(
decor.CountersKibiByte("% .2f / % .2f"),
),
mpb.AppendDecorators(
decor.EwmaETA(decor.ET_STYLE_GO, float64(total)/2048),
decor.Name(" ] "),
decor.AverageSpeed(decor.UnitKiB, "% .2f"),
),
)
// create proxy reader
proxyReader := bar.ProxyReader(reader)
defer proxyReader.Close()
// copy from proxyReader, ignoring errors
io.Copy(ioutil.Discard, proxyReader)
p.Wait()
}