12345678910111213141516171819202122232425 |
- package utils
- import (
- "fmt"
- "github.com/cheggaaa/pb/v3"
- )
- type Bar struct {
- pb *pb.ProgressBar
- }
- func NewBar(count int, MyStrStart, MyStrEnd string) *Bar {
- tmpl := fmt.Sprintf(`{{counters . }} {{ bar . "[" "-" (cycle . "↖" "↗" "↘" "↙" ) "_" "]"}} %s {{string . "MyStr" | green}} %s `, MyStrStart, MyStrEnd)
- bar := pb.ProgressBarTemplate(tmpl).Start(count)
- return &Bar{pb: bar}
- }
- func (b *Bar) Grow(num int, MyStrVal string) {
- b.pb.Set("MyStr", MyStrVal).Add(num)
- }
- func (b *Bar) Done() {
- b.pb.Finish()
- }
|