代码拉取完成,页面将自动刷新
同步操作将从 ShirDon-廖显东/goProgressor 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package main
import (
"fmt"
"math/rand"
"runtime"
"sync"
"time"
"gitee.com/shirdonl/goProgressor"
)
func main() {
runtime.GOMAXPROCS(runtime.NumCPU()) // use all available cpu cores
// create a new bar and prepend the task progress to the bar and fanout into 1k go routines
count := 1000
bar := goprogressor.AddBar(count).AppendCompleted().PrependElapsed()
bar.PrependFunc(func(b *goprogressor.Bar) string {
return fmt.Sprintf("Task (%d/%d)", b.Current(), count)
})
goprogressor.Start()
var wg sync.WaitGroup
// fanout into 1k go routines
for i := 0; i < count; i++ {
wg.Add(1)
go func() {
defer wg.Done()
time.Sleep(time.Millisecond * time.Duration(rand.Intn(500)))
bar.Incr()
}()
}
time.Sleep(time.Second) // wait for a second for all the go routines to finish
wg.Wait()
goprogressor.Stop()
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。