| 1 |
package main |
| 2 |
|
| 3 |
import ( |
| 4 |
"sync" |
| 5 |
"time" |
| 6 |
|
| 7 |
"github.com/gosuri/uiprogress" |
| 8 |
) |
| 9 |
|
| 10 |
func main() { |
| 11 |
waitTime := time.Millisecond * 100 |
| 12 |
uiprogress.Start() |
| 13 |
|
| 14 |
var wg sync.WaitGroup |
| 15 |
|
| 16 |
bar1 := uiprogress.AddBar(20).AppendCompleted().PrependElapsed() |
| 17 |
wg.Add(1) |
| 18 |
go func() { |
| 19 |
defer wg.Done() |
| 20 |
for bar1.Incr() { |
| 21 |
time.Sleep(waitTime) |
| 22 |
} |
| 23 |
}() |
| 24 |
|
| 25 |
bar2 := uiprogress.AddBar(40).AppendCompleted().PrependElapsed() |
| 26 |
wg.Add(1) |
| 27 |
go func() { |
| 28 |
defer wg.Done() |
| 29 |
for bar2.Incr() { |
| 30 |
time.Sleep(waitTime) |
| 31 |
} |
| 32 |
}() |
| 33 |
|
| 34 |
time.Sleep(time.Second) |
| 35 |
bar3 := uiprogress.AddBar(20).PrependElapsed().AppendCompleted() |
| 36 |
wg.Add(1) |
| 37 |
go func() { |
| 38 |
defer wg.Done() |
| 39 |
for bar3.Incr() { |
| 40 |
time.Sleep(waitTime) |
| 41 |
} |
| 42 |
}() |
| 43 |
|
| 44 |
wg.Wait() |
| 45 |
} |