You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I'm trying to get an output of logs with a progress bar sticking on the bottom of the window. I've been adapting the example to try that:
diff--gita/demo/main.gob/demo/main.goindexd032073..739ae15100644---a/demo/main.go+++b/demo/main.go
@@ -15,7+15,8 @@ funcmain() {
// some arbitrary totals for our progress bars// in practice, these could be file sizes or similarmediumTotal:=200// mediumTotal, smallTotal, largerTotal := 150, 100, 200// make some output for the screen// the MakeBar(total, prependString) returns a method that you can pass progress into
@@ -29,11+30,11 @@ funcmain() {
progressBars.Println()
progressBars.Println("We can separate bars with blocks of text, or have them grouped.\n")
// barProgress2 := progressBars.MakeBar(smallTotal, "2nd - with description:")// barProgress3 := progressBars.MakeBar(largerTotal, "3rd")// barProgress4 := progressBars.MakeBar(mediumTotal, "4th")// barProgress5 := progressBars.MakeBar(smallTotal, "5th")// barProgress6 := progressBars.MakeBar(largerTotal, "6th")progressBars.Println("And we can have blocks of text as we wait for progress bars to complete...")
@@ -49,55+50,59 @@ funcmain() {
*/wg:=&sync.WaitGroup{}
wg.Add(61)
gofunc() {
// do something asyn that we can get updates upon// every time an update comes in, tell the bar to re-draw// this could be based on transferred bytes or similarfori:=0; i<=mediumTotal; i++ {
barProgress1(i)
ifi%10==0 {
// progressBars.Println("It is best to use the print wrappers to keep output synced up.")progressBars.Bars[0].Prepend+=fmt.Sprintf("#%v: wef wef wef wef wef wf wef\n", i)
}
time.Sleep(time.Millisecond*15)
}
wg.Done()
}()
// go func() {// for i := 0; i <= smallTotal; i++ {// barProgress2(i)// time.Sleep(time.Millisecond * 25)// }// wg.Done()// }()// go func() {// for i := 0; i <= largerTotal; i++ {// barProgress3(i)// time.Sleep(time.Millisecond * 12)// }// wg.Done()// }()// go func() {// for i := 0; i <= mediumTotal; i++ {// barProgress4(i)// time.Sleep(time.Millisecond * 10)// }// wg.Done()// }()// go func() {// for i := 0; i <= smallTotal; i++ {// barProgress5(i)// time.Sleep(time.Millisecond * 20)// }// wg.Done()// }()// go func() {// for i := 0; i <= largerTotal; i++ {// barProgress6(i)// time.Sleep(time.Millisecond * 10)// }// wg.Done()// }()wg.Wait()
// continue doing other work
Hi @fenollp ,
This project is not actively maintained - it was more of a demo to see how someone could do loading bars similar to how they might accomplish it in Docker. I'm swamped, and don't have the time to dig in, sorry. Without digging into your code, if I were you, I would see if the example runs as you expect. If yes, then try to structure your usage in the same way. The key is that the calls to the bar progress update happen concurrently (ie, in a goroutine) while the printing of the bars happens in your "root" code (probably main).
Hi! I'm trying to get an output of logs with a progress bar sticking on the bottom of the window. I've been adapting the example to try that:
but output looks nothing at all like
apt upgrade
:Any ideas?
The text was updated successfully, but these errors were encountered: