當前位置: 首頁>>代碼示例>>Golang>>正文


Golang ProgressBar.Set64方法代碼示例

本文整理匯總了Golang中github.com/cheggaaa/pb.ProgressBar.Set64方法的典型用法代碼示例。如果您正苦於以下問題:Golang ProgressBar.Set64方法的具體用法?Golang ProgressBar.Set64怎麽用?Golang ProgressBar.Set64使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/cheggaaa/pb.ProgressBar的用法示例。


在下文中一共展示了ProgressBar.Set64方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: updateProgress

func (ld *loader) updateProgress(bar *pb.ProgressBar) {
	bar.Set64(ld.r.BytesRead())
}
開發者ID:gwatts,項目名稱:dyndump,代碼行數:3,代碼來源:cmd_load.go

示例2: 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
}
開發者ID:kildevaeld,項目名稱:lang,代碼行數:61,代碼來源:install.go

示例3: init

	Short: "A brief description of your command",
	Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:

Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
	Run: func(cmd *cobra.Command, args []string) {
		// TODO: Work your own magic here
		var bar *pb.ProgressBar

		err := service.Update(func(step lang.Step, p, t int64) {
			if bar == nil {
				bar = createBar("Updating manifests", t)
			}
			bar.Set64(p)
		})

		if bar != nil {
			bar.Finish()
		}

		if err != nil {
			printError(err)
		}

	},
}

func init() {
	RootCmd.AddCommand(updateCmd)
開發者ID:kildevaeld,項目名稱:lang,代碼行數:31,代碼來源:update.go

示例4: updateProgress

func (d *dumper) updateProgress(bar *pb.ProgressBar) {
	bar.Set64(d.f.Stats().BytesRead)
}
開發者ID:gwatts,項目名稱:dyndump,代碼行數:3,代碼來源:cmd_dump.go

示例5: updateProgress

func (d *deleter) updateProgress(bar *pb.ProgressBar) {
	bar.Set64(d.del.Completed())
}
開發者ID:gwatts,項目名稱:dyndump,代碼行數:3,代碼來源:cmd_delete.go

示例6:

					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 + "\r  installed")
		}
		/*if bar != nil {
			bar.NotPrint = true
			bar.FinishPrint(ascii2.EraseLine + ascii2.CursorUp(1) + ascii2.EraseLine + "  " + stepToMsg(currentStep) + "\t\tDone")

		}
		if process != nil {
開發者ID:kildevaeld,項目名稱:lang,代碼行數:31,代碼來源:test.go

示例7: finishProgressBar

func finishProgressBar(pb *pb.ProgressBar) {
	pb.Set64(pb.Total)
	pb.Finish()
}
開發者ID:hagen1778,項目名稱:fasthttploader,代碼行數:4,代碼來源:loader.go


注:本文中的github.com/cheggaaa/pb.ProgressBar.Set64方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。