summaryrefslogtreecommitdiff
path: root/vendor/gopkg.in/cheggaaa/pb.v1/reader.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gopkg.in/cheggaaa/pb.v1/reader.go')
-rw-r--r--vendor/gopkg.in/cheggaaa/pb.v1/reader.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/vendor/gopkg.in/cheggaaa/pb.v1/reader.go b/vendor/gopkg.in/cheggaaa/pb.v1/reader.go
new file mode 100644
index 000000000..9f3148b54
--- /dev/null
+++ b/vendor/gopkg.in/cheggaaa/pb.v1/reader.go
@@ -0,0 +1,25 @@
+package pb
+
+import (
+ "io"
+)
+
+// It's proxy reader, implement io.Reader
+type Reader struct {
+ io.Reader
+ bar *ProgressBar
+}
+
+func (r *Reader) Read(p []byte) (n int, err error) {
+ n, err = r.Reader.Read(p)
+ r.bar.Add(n)
+ return
+}
+
+// Close the reader when it implements io.Closer
+func (r *Reader) Close() (err error) {
+ if closer, ok := r.Reader.(io.Closer); ok {
+ return closer.Close()
+ }
+ return
+}