https://github.com/muesli/goprogressbar
Print progress bars on the console with Go
https://github.com/muesli/goprogressbar
hacktoberfest
Last synced: about 2 months ago
JSON representation
Print progress bars on the console with Go
- Host: GitHub
- URL: https://github.com/muesli/goprogressbar
- Owner: muesli
- License: mit
- Created: 2016-09-27T04:33:05.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2020-08-29T22:12:46.000Z (almost 5 years ago)
- Last Synced: 2025-05-01T16:55:26.072Z (about 2 months ago)
- Topics: hacktoberfest
- Language: Go
- Size: 34.2 KB
- Stars: 22
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
goprogressbar
=============[](https://github.com/muesli/goprogressbar/releases)
[](https://github.com/muesli/goprogressbar/actions)
[](https://coveralls.io/github/muesli/goprogressbar?branch=master)
[](http://goreportcard.com/report/muesli/goprogressbar)
[](https://pkg.go.dev/github.com/muesli/goprogressbar)Golang helper to print one or many progress bars on the console
## Installation
Make sure you have a working Go environment (Go 1.9 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
## Example
```go
package mainimport (
"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%
```