1package pb_test 2 3import ( 4 "math/rand" 5 "sync" 6 "time" 7 8 "gopkg.in/cheggaaa/pb.v1" 9) 10 11func Example_multiple() { 12 // create bars 13 first := pb.New(200).Prefix("First ") 14 second := pb.New(200).Prefix("Second ") 15 third := pb.New(200).Prefix("Third ") 16 // start pool 17 pool, err := pb.StartPool(first, second, third) 18 if err != nil { 19 panic(err) 20 } 21 // update bars 22 wg := new(sync.WaitGroup) 23 for _, bar := range []*pb.ProgressBar{first, second, third} { 24 wg.Add(1) 25 go func(cb *pb.ProgressBar) { 26 for n := 0; n < 200; n++ { 27 cb.Increment() 28 time.Sleep(time.Millisecond * time.Duration(rand.Intn(100))) 29 } 30 cb.Finish() 31 wg.Done() 32 }(bar) 33 } 34 wg.Wait() 35 // close pool 36 pool.Stop() 37} 38