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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
goprogressbar
=============
Golang helper to print one or many progress bars on the console
## Installation
Make sure you have a working Go environment (Go 1.4 or higher is required).
See the [install instructions](http://golang.org/doc/install.html).
To install goprogressbar, simply run:
go get github.com/muesli/goprogressbar
If you want to build it manually:
cd $GOPATH/src/github.com/muesli/goprogressbar
go get -u -v
go build
## Example
```go
package main
import (
"fmt"
"strconv"
"time"
"github.com/muesli/goprogressbar"
)
func main() {
mpb := goprogressbar.MultiProgressBar{}
for i := 0; i < 10; i++ {
pb := &goprogressbar.ProgressBar{
Text: "Progress " + strconv.FormatInt(int64(i+1), 10),
Total: 100,
Current: 0,
Width: 60,
}
mpb.AddProgressBar(pb)
}
pb := &goprogressbar.ProgressBar{
Text: "Overall Progress",
Total: 1000,
Current: 0,
Width: 60,
}
mpb.AddProgressBar(pb)
// fill progress bars one after another
for j := 0; j < 10; j++ {
for i := 1; i <= 100; i++ {
p := mpb.ProgressBars[j]
p.Current = int64(i)
p.RightAlignedText = fmt.Sprintf("%d of %d", i, p.Total)
pb.Current++
mpb.LazyPrint()
time.Sleep(23 * time.Millisecond)
}
}
fmt.Println()
}
```
## What it looks like
```
Progress 1 100 of 100 [#################################################] 100.00%
Progress 2 100 of 100 [#################################################] 100.00%
Progress 3 89 of 100 [###########################################>-----] 89.00%
Progress 4 [#>-----------------------------------------------] 0.00%
Progress 5 [#>-----------------------------------------------] 0.00%
Progress 6 [#>-----------------------------------------------] 0.00%
Progress 7 [#>-----------------------------------------------] 0.00%
Progress 8 [#>-----------------------------------------------] 0.00%
Progress 9 [#>-----------------------------------------------] 0.00%
Progress 10 [#>-----------------------------------------------] 0.00%
Overall Progress [#############>-----------------------------------] 28.90%
```
## Development
[](https://godoc.org/github.com/muesli/goprogressbar)
[](https://travis-ci.org/muesli/goprogressbar)
[](https://coveralls.io/github/muesli/goprogressbar?branch=master)
[](http://goreportcard.com/report/muesli/goprogressbar)
|