PackageManager just because
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
521 B

3 years ago
  1. package ProgressBar
  2. import (
  3. "github.com/vbauerster/mpb"
  4. "github.com/vbauerster/mpb/decor"
  5. )
  6. var (
  7. P = mpb.New()
  8. )
  9. func InitBar(name string, total int) *mpb.Bar {
  10. var (
  11. bar *mpb.Bar
  12. )
  13. bar = P.AddBar(int64(total),
  14. mpb.PrependDecorators(
  15. decor.Name(name),
  16. decor.Percentage(decor.WCSyncSpace),
  17. ),
  18. mpb.AppendDecorators(
  19. // replace ETA decorator with "done" message, OnComplete event
  20. decor.OnComplete(
  21. decor.AverageETA(decor.ET_STYLE_GO, decor.WC{W: 4}), "done",
  22. ),
  23. ),
  24. )
  25. return bar
  26. }