gitee.com/quant1x/gox@v1.21.2/progressbar/README.md (about) 1 # pgbar 2 3 a progess bar write by golang 4 5 ## use 6 7 ```go 8 import ( 9 "github.com/qianlnk/progressbar" 10 ) 11 12 pgb := pgbar.New("多线程进度条") 13 pgbar.Println("进度条1") 14 b := pgb.NewBar("1st", 20000) 15 pgbar.Println("进度条2") 16 b2 := pgb.NewBar("2st", 10000) 17 pgbar.Println("进度条3") 18 b3 := pgb.NewBar("3st", 30000) 19 20 b.SetSpeedSection(900, 100) 21 b2.SetSpeedSection(900, 100) 22 b3.SetSpeedSection(900, 100) 23 24 pgbar.Println("独立进度条") 25 b4 := pgbar.NewBar(0, "4st", 4000) 26 var wg sync.WaitGroup 27 wg.Add(4) 28 go func() { 29 defer wg.Done() 30 for i := 0; i < 20000; i++ { 31 b.Add() 32 time.Sleep(time.Second / 2000) 33 } 34 }() 35 36 go func() { 37 defer wg.Done() 38 for i := 0; i < 10000; i++ { 39 b2.Add() 40 time.Sleep(time.Second / 1000) 41 } 42 }() 43 go func() { 44 defer wg.Done() 45 for i := 0; i < 30000; i++ { 46 b3.Add() 47 time.Sleep(time.Second / 3000) 48 } 49 }() 50 51 go func() { 52 defer wg.Done() 53 for i := 0; i < 4000; i++ { 54 b4.Add() 55 time.Sleep(time.Second / 300) 56 } 57 }() 58 wg.Wait() 59 ``` 60 61 ![](https://github.com/qianlnk/pgbar/blob/master/demo.gif)