reader.go 229 B

1234567891011121314151617
  1. package pb
  2. import (
  3. "io"
  4. )
  5. // It's proxy reader, implement io.Reader
  6. type Reader struct {
  7. io.Reader
  8. bar *ProgressBar
  9. }
  10. func (r *Reader) Read(p []byte) (n int, err error) {
  11. n, err = r.Reader.Read(p)
  12. r.bar.Add(n)
  13. return
  14. }