A lightweight, single-file progress bar for Go CLI tools.
go get github.com/elliota43/simplebar- The Simple Way
Just give it a total number, and it works.
package main
import (
"time"
"github.com/elliota43/simplebar"
)
func main() {
bar := simplebar.New(50) // Default style: [=>-]
for i := 0; i < 50; i++ {
time.Sleep(50 * time.Millisecond)
bar.Add(1)
}
bar.Finish()
}- The Custom Way
Customize the look, width, or output destination (e.g., to a file or buffer)
bar := simplebar.New(100,
simplebar.WithWidth(40),
simplebar.WithPrefix("Downloading: "),
simplebar.WithGraphChars()"█", "▒", "░")
)- Zero Dependencies: It uses only the Go standard library and is less than 200 lines of code.
- Thread Safe: Safe to call
bar.Add()from concurrent goroutines. - ETA Calculation: Automatically estimates time remaining.
- Unicode Safe: Handles multi-byte characters (like emojis/blocks) correctly without crashing.
MIT