Skip to content

Latest commit

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

A very basic console progress bar for Go

This is a basic exercise to familiarize myself with the Go language. There are many other more feature-rich progress bars out there, but I think that this is a good practical problem to train on.

Usage

package main
import (
"github.com/lindronics/progressbar""time"
)
funcmain() {
b:=progressbar.StartNew(50)
fori:=0; i<50; i++ {
b.Increment()
time.Sleep(20*time.Millisecond)
}
b.Finish()
}

Example output

Progress: |▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓| 100.00% - 0.63s
Wall time: 0.634013

Optional parameters

// Set display width of the progress barb:=progressbar.StartNew(100, progressbar.BarWidth(100))
// Determine whether to show a percentage next to the barb:=progressbar.StartNew(100, progressbar.BarShowPercent(false))
// Determine whether to show elapsed time next to the barb:=progressbar.StartNew(100, progressbar.BarShowTime(false))

Theming

theme:=Theme{
StartChar: '[',
EndChar: ']',
ProgressChar: '=',
}
b:=progressbar.StartNew(100, progressbar.BarTheme(theme)

Todo

  • Review thread safety
  • Error handling
  • More extensive theming
  • Testing

About

Very basic console progress bar for Go

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages