https://github.com/snakeice/gogress
Golang multi progress
https://github.com/snakeice/gogress
go golang multiprogress progress progressbar
Last synced: 13 days ago
JSON representation
Golang multi progress
- Host: GitHub
- URL: https://github.com/snakeice/gogress
- Owner: snakeice
- License: gpl-3.0
- Created: 2020-02-18T20:22:54.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-05-30T04:11:51.000Z (12 months ago)
- Last Synced: 2025-05-05T17:18:17.816Z (14 days ago)
- Topics: go, golang, multiprogress, progress, progressbar
- Language: Go
- Homepage:
- Size: 75.2 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gogress
Simple terminal progress bar with Go.
Features:
- Customizable progress bar
- Multi-progress bar
- Multi-threaded multi-progress bar
- IO wrapperBased on [cheggaaa/pb](https://github.com/cheggaaa/pb)
# Sample usage - Simple progress bar
```go
package mainimport (
"time""github.com/snakeice/gogress"
)const TOTAL = 500
func main() {
bar := gogress.New(TOTAL)
bar.Start()
bar.Prefix("Downloading life")
for i := 1; i <= TOTAL; i++ {
bar.Inc()
time.Sleep(time.Second / 120)
}
bar.FinishPrint("All Solved")
}
```[](https://asciinema.org/a/wqZKNwxiQErdrVG4fDlFdQqLZ)
# Sample decorator
```go
package mainimport (
"time""github.com/snakeice/gogress"
"github.com/snakeice/gogress/format"
)const TOTAL = 500
func main() {
barFormat := format.ProgressFormat{
BoxStart: "|",
BoxEnd: "|",
Empty: "_",
Current: ">",
Completed: "-",
SpinString: "\\|/-",
}template := `{{prefix . 2 | green }} {{spin . 1 | rndcolor }} {{percent . 1 | cyan }} {{counter . 1 | red }} {{speed . 1 | blue}}`
bar := gogress.New(TOTAL)
if err := bar.SetTemplate(template); err != nil {
panic(err)
}bar.Format = barFormat
bar.Prefix("Processing")bar.Start()
bar.Prefix("Downloading life")
for i := 1; i <= TOTAL; i++ {
bar.Inc()
time.Sleep(time.Second / 120)
}
bar.FinishPrint("All Solved")
}
```[](https://asciinema.org/a/BjDqCQYQyQGZJeD3D61absJfq)
# Sample usage - Multi-progress bar
```go
package mainimport (
"math/rand"
"strconv"
"time""github.com/snakeice/gogress"
)const (
TOTAL = 100
BARS = 3
)func processBar(bar *gogress.Progress) {
for bar.GetMax() > bar.GetCurrent() {
bar.Inc()
time.Sleep(time.Millisecond * time.Duration(rand.Intn(100)))
}bar.Finish()
}func main() {
pool := gogress.NewPool()
pool.Start()
for i := 0; i < BARS; i++ {
bar := pool.NewBar(TOTAL)
bar.Prefix("Processing " + strconv.Itoa(i))
go processBar(bar)
}bar := pool.NewBar(TOTAL)
bar.Add(50).Prefix("Other processing")
processBar(bar)
pool.RemoveBar(bar)pool.Wait()
}
```[](https://asciinema.org/a/REaVd9hpZ6iEZN6LYz0uqEG4B)