File: main.go

package info (click to toggle)
golang-github-gosuri-uilive 0.0~git20170323.ac356e6-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 244 kB
  • sloc: makefile: 4
file content (26 lines) | stat: -rw-r--r-- 511 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
package main

import (
	"fmt"
	"time"

	"github.com/gosuri/uilive"
)

func main() {
	writer := uilive.New()

	// start listening for updates and render
	writer.Start()

	for _, f := range []string{"Foo.zip", "Bar.iso"} {
		for i := 0; i <= 50; i++ {
			fmt.Fprintf(writer, "Downloading %s.. (%d/%d) GB\n", f, i, 50)
			time.Sleep(time.Millisecond * 25)
		}
		fmt.Fprintf(writer.Bypass(), "Downloaded %s\n", f)
	}

	fmt.Fprintln(writer, "Finished: Downloaded 100GB")
	writer.Stop() // flush and stop rendering
}