mirror of https://github.com/docker/docs.git
Removed unused utility future.Pv()
This commit is contained in:
parent
0208b6accd
commit
deb603aaf4
|
@ -1,9 +1,6 @@
|
||||||
package future
|
package future
|
||||||
|
|
||||||
import (
|
import ()
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
)
|
|
||||||
|
|
||||||
func Go(f func() error) chan error {
|
func Go(f func() error) chan error {
|
||||||
ch := make(chan error)
|
ch := make(chan error)
|
||||||
|
@ -12,26 +9,3 @@ func Go(f func() error) chan error {
|
||||||
}()
|
}()
|
||||||
return ch
|
return ch
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pv wraps an io.Reader such that it is passed through unchanged,
|
|
||||||
// but logs the number of bytes copied (comparable to the unix command pv)
|
|
||||||
func Pv(src io.Reader, info io.Writer) io.Reader {
|
|
||||||
var totalBytes int
|
|
||||||
data := make([]byte, 2048)
|
|
||||||
r, w := io.Pipe()
|
|
||||||
go func() {
|
|
||||||
for {
|
|
||||||
if n, err := src.Read(data); err != nil {
|
|
||||||
w.CloseWithError(err)
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
totalBytes += n
|
|
||||||
fmt.Fprintf(info, "--> %d bytes\n", totalBytes)
|
|
||||||
if _, err = w.Write(data[:n]); err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
return r
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue