File: README.md

package info (click to toggle)
golang-github-coreos-ioprogress 0.0~git20151023.0.4637e49-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 68 kB
  • ctags: 31
  • sloc: makefile: 2
file content (42 lines) | stat: -rw-r--r-- 1,039 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# ioprogress

ioprogress is a Go (golang) library with implementations of `io.Reader`
and `io.Writer` that draws progress bars. The primary use case for these
are for CLI applications but alternate progress bar writers can be supplied
for alternate environments.

## Example

![Progress](http://g.recordit.co/GO5HxT16QH.gif)

## Installation

Standard `go get`:

```
$ go get github.com/mitchellh/ioprogress
```

## Usage

Here is an example of outputting a basic progress bar to the CLI as
we're "downloading" from some other `io.Reader` (perhaps from a network
connection):

```go
// Imagine this came from some external source, such as a network connection,
// and that we have the full size of it, such as from a Content-Length HTTP
// header.
var r io.Reader

// Create the progress reader
progressR := &ioprogress.Reader{
	Reader: r,
	Size:   rSize,
}

// Copy all of the reader to some local file f. As it copies, the
// progressR will write progress to the terminal on os.Stdout. This is
// customizable.
io.Copy(f, progressR)
```