kevinschoon-pomo/vendor/github.com/gosuri/uilive/example/main.go

27 lines
511 B
Go
Raw Normal View History

2018-01-21 11:41:29 +01:00
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
}