Codebase list golang-github-vbauerster-mpb / f27ec4a example / singleBar / main.go
f27ec4a

Tree @f27ec4a (Download .tar.gz)

main.go @f27ec4araw · history · blame

package main

import (
	"fmt"
	"math/rand"
	"time"

	"github.com/vbauerster/mpb"
)

func main() {

	name := "Single bar:"
	p := mpb.New()
	bar := p.AddBar(100).PrependName(name, 0).AppendPercentage()

	for i := 0; i < 100; i++ {
		time.Sleep(time.Duration(rand.Intn(100)) * time.Millisecond)
		bar.Incr(1)
	}

	p.Stop()
	fmt.Println("stop")
}