Created
December 8, 2015 08:07
-
-
Save apoorvam/bea7a0d0e7819a053d07 to your computer and use it in GitHub Desktop.
Print long messages using uilive, to show progress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| "time" | |
| "github.com/gosuri/uilive" | |
| ) | |
| func main() { | |
| writer := uilive.New() | |
| // start listening for updates and render | |
| writer.Start() | |
| for i := 0; i <= 100; i++ { | |
| fmt.Fprintf(writer, "Downloadinnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnng.. (%d/%d) GB\n", i, 100) | |
| time.Sleep(time.Second) | |
| } | |
| writer.Stop() // flush and stop rendering | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment