funcprogress(reader io.Reader) {
r=NewReader("an_file.tar", reader, 100*time.Millisecond)
deferr.Close()
varcountuint64// This goroutine consumes the channel and concatenates the count to display// the total as it increases.gofunc(r*Reader) {
fortick:=ranger.C {
count+=tick.Valuefmt.Printf("\r%d", count)
}
fmt.Println()
}(r)
// use r like you normally would; progress will be reported to C every 100// milliseconds.if_, err:=io.Copy(ioutil.Discard, r); err!=nil {
panic(err)
}
}Erik Hollensbe github@hollensbe.org