File: single.go

package info (click to toggle)
golang-github-muesli-goprogressbar 0.1%2Bgit20180221.8ba3888-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 96 kB
  • sloc: makefile: 5
file content (34 lines) | stat: -rw-r--r-- 523 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
 * goprogressbar
 *     Copyright (c) 2016-2017, Christian Muehlhaeuser <muesli@gmail.com>
 *
 *   For license see LICENSE
 */

package main

import (
	"fmt"
	"time"

	"github.com/muesli/goprogressbar"
)

func main() {
	pb := &goprogressbar.ProgressBar{
		Text:    "Current Progress",
		Total:   1000,
		Current: 0,
		Width:   60,
	}

	for i := 1; i <= 1000; i++ {
		pb.PrependText = fmt.Sprintf("%d of %d", i, pb.Total)
		pb.Current = int64(i)

		time.Sleep(23 * time.Millisecond)
		pb.LazyPrint()
	}

	fmt.Println()
}