本文整理匯總了Golang中github.com/cheggaaa/pb.ProgressBar.SetWidth方法的典型用法代碼示例。如果您正苦於以下問題:Golang ProgressBar.SetWidth方法的具體用法?Golang ProgressBar.SetWidth怎麽用?Golang ProgressBar.SetWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cheggaaa/pb.ProgressBar
的用法示例。
在下文中一共展示了ProgressBar.SetWidth方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: install
func install(l, version string) error {
var currentStep lang.Step
var bar *pb.ProgressBar
var process *Process
fmt.Printf("Installing %[email protected]%s\n", l, version)
err := service.Install(l, version, binaryFlag, func(step lang.Step, progress, total int64) {
if currentStep != step {
if bar != nil {
bar.NotPrint = true
bar.Finish()
fmt.Printf(ascii2.EraseLine)
bar = nil
}
if process != nil {
process.Done("")
process = nil
}
if total > 0 {
bar = pb.New64(total).Prefix(" " + stepToMsg(step) + "\t\t")
bar.SetWidth(40)
bar.ShowCounters = false
//fmt.Printf("%s\n", step)
//bar.NotPrint = true
bar.Start()
currentStep = step
} else {
process := &Process{Msg: stepToMsg(step) + "\t\t"}
process.Start()
}
}
if bar != nil {
bar.Set64(progress)
}
})
if bar != nil {
bar.NotPrint = true
bar.Finish()
fmt.Printf(ascii2.EraseLines(2) + ascii2.EraseLine + fmt.Sprintf(" %s installed", l))
}
if process != nil {
process.Done("\n")
}
//fmt.Printf(ascii2.EraseLine + ascii2.CursorUp(1) + ascii2.EraseLine)
if err != nil {
fmt.Printf("Could not install %[email protected]%s: \n %s\n", l, version, err.Error())
} else {
fmt.Printf(" %[email protected]%s installed!\n\n", l, version)
}
return err
}
示例2:
if bar != nil {
bar.NotPrint = true
bar.Finish()
fmt.Printf(ascii2.EraseLine)
bar = nil
}
if process != nil {
process.Done("")
process = nil
}
if total > 0 {
bar = pb.New64(total).Prefix(" " + stepToMsg(step) + "\t\t")
bar.SetWidth(40)
bar.ShowCounters = false
//fmt.Printf("%s\n", step)
//bar.NotPrint = true
bar.Start()
currentStep = step
} else {
process := &Process{Msg: " " + stepToMsg(step) + "\t\t"}
process.Start()
}
}
if bar != nil {
bar.Set64(progress)