* Vendors packages * Adds a Makefile that uses docker to build a static binary against musl using alpine linux. Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
25 lines
496 B
Go
25 lines
496 B
Go
package ioprogress
|
|
|
|
import (
|
|
"io"
|
|
)
|
|
|
|
// ProgressReader is a wrapper around ReadCloser which allows for progress tracking
|
|
type ProgressReader struct {
|
|
io.ReadCloser
|
|
Tracker *ProgressTracker
|
|
}
|
|
|
|
// Read in ProgressReader is the same as io.Read
|
|
func (pt *ProgressReader) Read(p []byte) (int, error) {
|
|
// Do normal reader tasks
|
|
n, err := pt.ReadCloser.Read(p)
|
|
|
|
// Do the actual progress tracking
|
|
if pt.Tracker != nil {
|
|
pt.Tracker.total += int64(n)
|
|
pt.Tracker.update(n)
|
|
}
|
|
|
|
return n, err
|
|
}
|