This library instruments io.Reader
/io.Writer
with progress printer.
See catp
for an example.
var pr = &progress.Progress{
Interval: 5 * time.Second,
Print: func(status progress.ProgressStatus) {
println(Status(status))
},
}
func cat(filename string) {
file, err := os.Open(filename)
if err != nil {
log.Fatal(err)
}
defer file.Close()
st, err := file.Stat()
if err != nil {
log.Fatalf("failed to read file stats %s: %s", filename, err)
}
cr := &progress.CountingReader{Reader: file}
pr.Start(st.Size, cr.Bytes, cr.Lines, filename)
defer pr.Stop()
readFile(cr)
}