https://github.com/hekmon/liveprogress
liveprogress is a golang library allowing to print and update progress bars on a terminal
https://github.com/hekmon/liveprogress
go golang library live progress progressbar terminal ui uiprogress update
Last synced: 5 months ago
JSON representation
liveprogress is a golang library allowing to print and update progress bars on a terminal
- Host: GitHub
- URL: https://github.com/hekmon/liveprogress
- Owner: hekmon
- License: mit
- Created: 2024-04-15T16:33:01.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-08T20:33:05.000Z (over 1 year ago)
- Last Synced: 2025-10-06T19:38:27.085Z (9 months ago)
- Topics: go, golang, library, live, progress, progressbar, terminal, ui, uiprogress, update
- Language: Go
- Homepage:
- Size: 1.55 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# liveprogress
[](https://pkg.go.dev/github.com/hekmon/liveprogress/v2)
liveprogress is a golang library allowing to print and update progress bars on a terminal. It is heavily inspired by [uiprogress](https://github.com/gosuri/uiprogress) but redone on top of the forked [liveterm](https://github.com/hekmon/liveterm) library in order to take advantage of its enhancements.
In addition of the features of [liveterm](https://github.com/hekmon/liveterm), it also add (or changes):
* Automatic bar length if its `width` is 0
* Bars characters are runes (Unicode support thru `liveterm`)
* Remove unecessary mutexes
* usage of atomic operations for bar progress
* decorators can be added only when instanciating the bar
* Custom (dynamic) lines that can be anything (not necessarly a progress bar)
* Main line concept: a bar or a custom line that will always be printed last (usefull for global progress when others lines above it indicate specific progress)
* Ability to style the bar and decorators using [termenv](https://github.com/muesli/termenv) styles
## Examples
### Simple
Code available [here](examples/simple/main.go).
```go
if err := liveprogress.Start(); err != nil {
panic(err)
}
bar := liveprogress.AddBar(
liveprogress.WithPrependPercent(liveprogress.BaseStyle()),
liveprogress.WithAppendDecorator(func(bar *liveprogress.Bar) string {
return " Remaining:"
}),
liveprogress.WithAppendTimeRemaining(liveprogress.BaseStyle()),
)
// By default a bar total is set to 100
for i := 0; i < liveprogress.DefaultTotal; i++ {
// Wait a random time
time.Sleep(time.Duration(rand.Intn(300)) * time.Millisecond)
// Increment the bar
bar.CurrentIncrement()
}
if err := liveprogress.Stop(true); err != nil {
panic(err)
}
fmt.Println("By setting the Stop() bool parameter to true, the progress bar is cleared at stop.")
```

### Advanced
See full source code [here](examples/advanced/main.go).

## Installation
```bash
go get -v github.com/hekmon/liveprogress/v2
```