代码拉取完成,页面将自动刷新
package main
import (
"fmt"
"math/rand"
"sync"
"time"
"gitee.com/shirdonl/goProgressor"
"gitee.com/shirdonl/goProgressor/util/strutil"
)
var steps = []string{
"downloading source",
"installing deps",
"compiling",
"packaging",
"seeding database",
"deploying",
"staring servers",
}
func main() {
fmt.Println("apps: deployment started: app1, app2")
goprogressor.Start()
var wg sync.WaitGroup
wg.Add(1)
go deploy("app1", &wg)
wg.Add(1)
go deploy("app2", &wg)
wg.Wait()
fmt.Println("apps: successfully deployed: app1, app2")
}
func deploy(app string, wg *sync.WaitGroup) {
defer wg.Done()
bar := goprogressor.AddBar(len(steps)).AppendCompleted().PrependElapsed()
bar.Width = 50
// prepend the deploy step to the bar
bar.PrependFunc(func(b *goprogressor.Bar) string {
return strutil.Resize(app+": "+steps[b.Current()-1], 22)
})
rand.Seed(500)
for bar.Incr() {
time.Sleep(time.Millisecond * time.Duration(rand.Intn(2000)))
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。