You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CloudflareSpeedTest/utils/progress.go

26 lines
526 B
Go

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()
}