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.
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()
}Progress: |▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓| 100.00% - 0.63s
Wall time: 0.634013
// 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))theme:=Theme{
StartChar: '[',
EndChar: ']',
ProgressChar: '=',
}
b:=progressbar.StartNew(100, progressbar.BarTheme(theme)- Review thread safety
- Error handling
- More extensive theming
- Testing