• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang pb.StartNew函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/cheggaaa/pb.StartNew函数的典型用法代码示例。如果您正苦于以下问题:Golang StartNew函数的具体用法?Golang StartNew怎么用?Golang StartNew使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了StartNew函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: HoldAuctionsFor

func HoldAuctionsFor(client types.RepPoolClient, instances []instance.Instance, representatives []string, rules types.AuctionRules, communicator types.AuctionCommunicator) ([]types.AuctionResult, time.Duration) {
	fmt.Printf("\nStarting Auctions\n\n")
	bar := pb.StartNew(len(instances))

	t := time.Now()
	semaphore := make(chan bool, rules.MaxConcurrent)
	c := make(chan types.AuctionResult)
	for _, inst := range instances {
		go func(inst instance.Instance) {
			semaphore <- true
			c <- communicator(types.AuctionRequest{
				Instance: inst,
				RepGuids: representatives,
				Rules:    rules,
			})
			<-semaphore
		}(inst)
	}

	results := []types.AuctionResult{}
	for _ = range instances {
		results = append(results, <-c)
		bar.Increment()
	}

	bar.Finish()

	return results, time.Since(t)
}
开发者ID:vito,项目名称:auction,代码行数:29,代码来源:auctioneer.go


示例2: main

func main() {
	// Init...
	cfg := Config{
		CommonConfig: app.CommonConfig{
			MetaSize: 8,
			TileSize: 256,
		},
	}

	app.App.Configure("Copy", &cfg)

	if cfg.Copy.Threads < 1 {
		cfg.Copy.Threads = 1
	}

	fromI, err := plugins.DefaultPluginStore.Create(cfg.Copy.From.Plugin, cfg.Copy.From.PluginConfig)
	if err != nil {
		log.Fatal(err)
	}
	from, ok := fromI.(gopnik.CachePluginInterface)
	if !ok {
		log.Fatal("Invalid cache plugin type")
	}

	toI, err := plugins.DefaultPluginStore.Create(cfg.Copy.To.Plugin, cfg.Copy.To.PluginConfig)
	if err != nil {
		log.Fatal(err)
	}
	to, ok := toI.(gopnik.CachePluginInterface)
	if !ok {
		log.Fatal("Invalid cache plugin type")
	}

	// Load plan...
	coords, err := loadPlanFile()
	if err != nil {
		log.Fatal(err)
	}

	// Process...
	bar := pb.StartNew(len(coords))
	var barMu sync.Mutex
	var wg sync.WaitGroup

	for k := 0; k < cfg.Copy.Threads; k++ {
		wg.Add(1)
		go func(k int) {
			defer wg.Done()
			for i := k; i < len(coords); i += cfg.Copy.Threads {
				copyMetaTile(coords[i], &cfg, from, to)

				barMu.Lock()
				bar.Increment()
				barMu.Unlock()
			}
		}(k)
	}
	wg.Wait()
	bar.FinishPrint("Done")
}
开发者ID:mikhailborodin,项目名称:gopnik,代码行数:60,代码来源:main.go


示例3: getInitTweets

func (g *Game) getInitTweets(aliveNum int) {
	var progress *pb.ProgressBar
	if !g.debug {
		progress = pb.StartNew(aliveNum)
	}
	for y := 0; y < g.field.SizeY; y++ {
		for x := 0; x < g.field.SizeX; x++ {
			if g.field.Points[y][x].IsAlive {
				tweet := <-g.tweetCh
				if g.debug {
					emoji.Printf(":bird:Points[%v][%v]: %v\n", x, y, tweet)
				}
				g.field.Points[y][x].Str = tweet
				if !g.debug {
					progress.Increment()
				}
			}
		}
	}
	if g.debug {
		emoji.Println(":smile::smile::smile:Collected initial tweets:smile::smile::smile:")
	} else {
		e := emoji.Sprint(":smile::smile::smile:")
		progress.FinishPrint(e + "Collected initial tweets" + e)
	}
}
开发者ID:Rompei,项目名称:lgb,代码行数:26,代码来源:game.go


示例4: HostMerge

func HostMerge(List []Host, ShowBar bool) []string {
	count := 0
	filterList := []string{""}
	length := len(List)
	var bar *pb.ProgressBar
	if ShowBar == true {
		bar = pb.StartNew(length)
		bar.SetMaxWidth(80)
	}
	for _, Host := range List {
		length = len(filterList[count])
		if length == 0 {
			filterList[count] = Host.Hostname
		} else if length+Host.length() <= 255 && length != 0 {
			filterList[count] += "|"
			filterList[count] += Host.Hostname
		} else {
			count++
			filterList = append(filterList, Host.Hostname)
			// filterList[count] = Ref.Referrer
		}
		if ShowBar == true {
			bar.Increment()
			time.Sleep(time.Millisecond * 50)
		}
	}
	if ShowBar == true {
		bar.Finish()
	}
	return filterList
}
开发者ID:botsifter,项目名称:BotSifter-Go-Client,代码行数:31,代码来源:botsifter.go


示例5: doUpload

func doUpload(filelist []string) {
	length := len(filelist)

	if length == 0 {
		fmt.Println("No new tiles to upload")
		return
	}

	pb.BarStart = "["
	pb.BarEnd = "]"
	pb.Empty = " "
	pb.Current = "#"
	pb.CurrentN = ">"

	bar := pb.StartNew(length)

	c := initWorkers()
	go func() {
		for i := 0; i < length; i++ {
			uploadFile(filelist[i])
		}
	}()

	var total int
	for total < length {
		select {
		case <-c:
			total = total + 1
			bar.Increment()
		}
	}

	bar.Finish()
}
开发者ID:scottferg,项目名称:MC-Map-Uploader,代码行数:34,代码来源:main.go


示例6: main

func main() {
	jobs := makeJobs(ipNetParsed, 100)
	out := make(chan ILOInfo, 100)
	ipNetLen := len(ipNetParsed)

	scanbar := pb.StartNew(ipNetLen)
	scanbar = scanbar.Prefix("Scan net")
	scanbar.ShowTimeLeft = false

	wg := new(sync.WaitGroup)
	//Запуск воркеров
	for _, job := range jobs {
		wg.Add(1)
		go scan(job, out, scanbar, wg)
	}

	wg.Wait()
	close(out)

	ilo := []ILOInfo{}
	for info := range out {
		ilo = append(ilo, info)
	}
	scanbar.Finish()
	tableRender(ilo)
	fmt.Println("")
}
开发者ID:hdhog,项目名称:findilo,代码行数:27,代码来源:main.go


示例7: GenerateTestData

func GenerateTestData(
	directory string,
	fileCount, rowCount int,
	timeOrigin int64, timeDistance int,
	uidCount int,
	domainsFilename string,
	geoOrigin util.GeoPoint, geoDistance int,
) (filenames []string, err error) {
	domains, err := newDomains(domainsFilename)
	if err != nil {
		return nil, err
	}
	filenames = make([]string, fileCount)
	progressBar := pb.StartNew(fileCount)
	for i := 0; i < fileCount; i++ {
		filename, err := generateTestDataFile(
			directory,
			rowCount,
			timeOrigin, timeDistance,
			uidCount,
			domains,
			geoOrigin, geoDistance,
		)
		if err != nil {
			return nil, err
		}
		progressBar.Increment()
		filenames[i] = filename
	}
	progressBar.FinishPrint("All done!")
	return filenames, nil
}
开发者ID:habajca,项目名称:simple-log-search,代码行数:32,代码来源:main.go


示例8: main

func main() {
	// declare flags
	regionPtr := flag.String("region", "us-east-2", "AWS Region(default: us-east-2)")
	bucketPtr := flag.String("bucket", "backup", "Bucket path you wish to upload")
	srcPtr := flag.String("src", os.Getenv("PWD"), "src folder of files (default this folder)")
	keyPtr := flag.String("key", os.Getenv("AWS_ACCESS_KEY_ID"), "AWS_ACCESS_KEY_ID")
	secretPtr := flag.String("secret", os.Getenv("AWS_SECRET_ACCESS_KEY"), "AWS_SECRET_ACCESS_KEY")
	destPtr := flag.String("dest", "new", "Destination path of root directory where you wish the contents to go in the bucket, \nif your connection continues to timeout try lowering it")
	limitPtr := flag.Int("limit", "4", "Number of concurrent uploads")

	flag.BoolVar(&timeStamp, "timestamp", false, "append commitstamp to the destination the commit")
	flag.BoolVar(&debug, "debug", false, "enable debug mode")

	flag.Parse()

	p := []string{
		*destPtr,
	}

	if timeStamp {
		p = append(p, strconv.FormatInt(time.Now().Unix(), 10))
	}

	dest := strings.Join(p, ".")
	fmt.Println(dest)
	simpleS3 := s5.New(*srcPtr, dest, *bucketPtr, *keyPtr, *secretPtr, *regionPtr, *limitPtr, debug)
	bar := pb.StartNew(simpleS3.FileCount)
	bar.ShowTimeLeft = false
	bar.Format("[⚡- ]")

	simpleS3.Run(func() {
		bar.Increment()
	})
	bar.FinishPrint(fmt.Sprintf("Completed Uploading to %s/%s!", simpleS3.Bucket, simpleS3.Dest))
}
开发者ID:dring1,项目名称:stupid-simple-s3-backup,代码行数:35,代码来源:main.go


示例9: init

func (b *Boom) init() {
	if b.Client == nil {
		b.Client = &http.Client{}
	}
	b.results = make(chan *result, b.N)
	b.bar = pb.StartNew(b.N)
	b.start = time.Now()
}
开发者ID:kkbankol,项目名称:boom,代码行数:8,代码来源:run.go


示例10: ReadDB

func ReadDB(c *client.Client, sdb, ddb, cmd string) client.BatchPoints {

	q := client.Query{
		Command:  cmd,
		Database: sdb,
	}

	//get type client.BatchPoints
	var batchpoints client.BatchPoints

	response, err := c.Query(q)
	if err != nil {
		fmt.Printf("Fail to get response from database, read database error: %s\n", err.Error())
	}

	res := response.Results
	if len(res) == 0 {
		fmt.Printf("The response of database is null, read database error!\n")
	} else {

		res_length := len(res)
		for k := 0; k < res_length; k++ {

			//show progress of reading series
			count := len(res[k].Series)
			bar := pb.StartNew(count)
			for _, ser := range res[k].Series {

				//get type client.Point
				var point client.Point

				point.Measurement = ser.Name
				point.Tags = ser.Tags
				for _, v := range ser.Values {
					point.Time, _ = time.Parse(time.RFC3339, v[0].(string))

					field := make(map[string]interface{})
					l := len(v)
					for i := 1; i < l; i++ {
						if v[i] != nil {
							field[ser.Columns[i]] = v[i]
						}
					}
					point.Fields = field
					point.Precision = "s"
					batchpoints.Points = append(batchpoints.Points, point)
				}
				bar.Increment()
				time.Sleep(3 * time.Millisecond)
			}
			bar.FinishPrint("Read series has finished!\n")
		}
		batchpoints.Database = ddb
		batchpoints.RetentionPolicy = "default"
	}
	return batchpoints
}
开发者ID:guaiguaihw,项目名称:influxdb-move,代码行数:57,代码来源:client.go


示例11: runDBTasks

func runDBTasks(ids []int64, task func(int64) error) {

	// Progress bar
	bar := pb.StartNew(len(ids))

	// Cancel control
	done := make(chan struct{})
	quit := false

	// IDs to process, sent via channel
	tasks := make(chan int64, len(ids)+1)

	var errs []error
	var wg sync.WaitGroup

	// Only fire up a set number of worker processes
	for i := 0; i < getGophers(len(ids)); i++ {
		wg.Add(1)

		go func() {
			for id := range tasks {
				err := doTask(id, task, done)
				if err != nil {
					if !quit {
						close(done)
						quit = true
					}
					errs = append(
						errs,
						fmt.Errorf("Failed on ID %d : %+v", id, err),
					)
					break
				}
				bar.Increment()
			}
			wg.Done()
		}()
	}

	for _, id := range ids {
		tasks <- id
	}
	close(tasks)

	wg.Wait()
	if !quit {
		close(done)
	}

	if len(errs) == 0 {
		bar.Finish()
	}

	for _, err := range errs {
		handleErr(err)
	}
}
开发者ID:siparker,项目名称:export-vbulletin,代码行数:57,代码来源:db.go


示例12: Wait

func (c *ContentQueue) Wait() {
	finished := 0
	bar := pb.StartNew(len(c.items))
	for finished < len(c.items) {
		<-c.items[finished].Result
		finished++
		bar.Increment()
	}
	bar.Finish()
}
开发者ID:rubenv,项目名称:sitegen,代码行数:10,代码来源:sitegen.go


示例13: init

func (b *Boom) init() {
	if b.Client == nil {
		tr := &http.Transport{
			TLSClientConfig: &tls.Config{InsecureSkipVerify: b.AllowInsecure},
		}
		b.Client = &http.Client{Transport: tr}
	}
	b.results = make(chan *result, b.N)
	b.bar = pb.StartNew(b.N)
	b.start = time.Now()
}
开发者ID:josephyzhou,项目名称:boom,代码行数:11,代码来源:run.go


示例14: main

func main() {
	count := 6000
	bar := pb.StartNew(count)
	for i := 0; i < count; i++ {
		bar.Increment()
		time.Sleep(time.Millisecond)
	}
	bar.ShowBar = true
	bar.ShowSpeed = true
	bar.FinishPrint("The End!")
}
开发者ID:sumory,项目名称:gogist,代码行数:11,代码来源:progress.go


示例15: unzip

func unzip(filename, dest, ver string) {
	var path string
	if filename == "" {
		fmt.Println("Can't unzip ", filename)
		os.Exit(1)
	}

	/* if filename[:2] == "go" {
		dest = dest + ps + strings.Replace(filename, "go", "go"+ps+ver, 1)
	} else if filename[:2] == "li" {
		dest = dest + ps + strings.Replace(filename, "liteide", "liteide"+ps+ver, 1)
	} */

	reader, err := zip.OpenReader(filename)
	checkErr("Extract error::OpenArchive", err)
	defer reader.Close()

	fl := int(len(reader.Reader.File))
	bar := pb.StartNew(fl)
	bar.ShowPercent = true
	bar.ShowCounters = false
	bar.ShowTimeLeft = false
	bar.Prefix("Extracting " + filename[strings.LastIndex(filename, ps)+1:] + " ")
	bar.Start()
	for _, f := range reader.Reader.File {
		zipped, err := f.Open()
		checkErr("Extract error::", err)
		defer zipped.Close()

		// path := filepath.Join(dest, ver, "./", f.Name)
		if f.Name[:2] == "go" {
			path = filepath.Join(dest, "./", strings.Replace(f.Name, "go", "go"+ps+ver, 1))
		} else if f.Name[:2] == "li" {
			path = filepath.Join(dest, "./", strings.Replace(f.Name, "liteide", "liteide"+ps+ver, 1))
		}
		// fmt.Println(path)

		if f.FileInfo().IsDir() {
			os.MkdirAll(path, f.Mode())
		} else {
			writer, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE, f.Mode())
			checkErr("Extract error::OpenFileFromArchive", err)
			defer writer.Close()

			if _, err = io.Copy(writer, zipped); err != nil {
				fmt.Println(err)
				os.Exit(1)
			}
		}
		//  progress = (i / fl) * 100
		bar.Increment()
	}
	bar.Finish()
}
开发者ID:bvp,项目名称:gtvm,代码行数:54,代码来源:extract.go


示例16: SetNecessaryExifData

func SetNecessaryExifData(
	osi OsInterface, exifi ExifInterface, filepairs FilePairs) FilePairs {
	bar := pb.StartNew(len(filepairs))
	for count := range filepairs {
		bar.Increment()
		filepairs[count].DateTime = strings.Replace(strings.Split(
			*ExifGetDatetime(osi, exifi, filepairs[count].Raw),
			" ")[0][2:], ":", "", -1)
	}
	bar.Finish()
	return filepairs
}
开发者ID:ebrius,项目名称:focusfs,代码行数:12,代码来源:exifhelper.go


示例17: main

// TODO: File cookiejar
func main() {
	creds, err := loadCredentials()
	if err != nil {
		fmt.Printf("Failed to load credentials. (%s)\n", err)
		return
	}
	if len(os.Args) == 1 {
		fmt.Printf("Usage: %s <query>\n", os.Args[0])
		return
	}
	// Form a query by joining all the arguments.
	query := strings.Join(os.Args[1:], " ")

	client := megashares.New()
	// Attempt to login.
	for {
		if err := client.Login(creds.Username, creds.Password); err != nil {
			fmt.Printf("Failed to login: %s\n", err)
			creds = askForCredentials()
			// log.Fatalf("Couldn't login! Reason: %s\n", err)
		} else {
			break
		}
	}

	// Perform the search
	entries, _ := client.SearchEntries(query)

	// Print out the results of the search for the user to pick from.
	for i, entry := range entries {
		fmt.Fprintf(os.Stderr, "%d: %s\n", i, entry.Filename)
	}

	// Get a valid number to choose from from the input loop.
	// TODO: Allow for pagination by returning (choice, page).
	choice := getValidNumber(0, len(entries)-1)
	entry := entries[choice]

	fmt.Print(entry.Url)
	return
	if file, response, err := ContinueDownload(client.Client, entry.Filename, entry.Url); err != nil {
		log.Fatal(err)
	} else {
		defer file.Close()
		defer response.Body.Close()
		length := response.ContentLength
		// Initialize progress bar.
		bar := pb.StartNew(int(length)).SetUnits(pb.U_BYTES)
		bar.ShowSpeed = true
		writer := io.MultiWriter(file, bar)
		io.Copy(writer, response.Body)
	}
}
开发者ID:norcalli,项目名称:megashares,代码行数:54,代码来源:megashares-client.go


示例18: main

func main() {
	//defer profile.Start().Stop()
	kingpin.Version("0.0.1")
	kingpin.Parse()

	// check if config dir exists
	finfo, err := os.Stat(*confDir)
	if err != nil {
		log.Fatalf("Config directory %s does not exist\n", *confDir)
	}
	if !finfo.IsDir() {
		log.Fatalf("Config directory %s is not a directory\n", *confDir)
	}

	finfo, err = os.Stat(*templateDir)
	if err != nil {
		log.Printf("Config directory %s does not exist, try to fallback to templates/\n", *templateDir)
		*templateDir = "templates"
		finfo, err = os.Stat(*templateDir)
		if err != nil {
			log.Fatalf("Failed, no template directory found\n")
		}
	}
	templates = template.Must(template.ParseGlob(*templateDir + "/*.tmpl"))

	log.Printf("Create %d hosts with %d services each", *numHosts, *numServices)
	bar := pb.StartNew(*numHosts)
	// create a syncgroup to make sure all templates are written before exiting
	var wg sync.WaitGroup
	concurrency := 20 // limit number of parallel goroutines
	sem := make(chan bool, concurrency)
	for host := 0; host < *numHosts; host++ {
		sem <- true
		// add us to the syncgroup
		wg.Add(1)
		go func() {
			// remove from syncgroup if done
			defer wg.Done()
			defer func() { <-sem }()
			genHost()
			bar.Increment()
		}()
	}
	for i := 0; i < cap(sem); i++ {
		sem <- true
	}
	// exit if all subroutines are done
	wg.Wait()
	bar.FinishPrint("The End!")
}
开发者ID:formorer,项目名称:icinga2-configgen,代码行数:50,代码来源:icinga2-configgen.go


示例19: main

func main() {
	// fmt.Println("start")
	data := parseCsv(ListIp, Conf.Sep)
	bar := pb.StartNew(len(data))
	bar.ShowPercent = false
	for i := 0; i < len(data); i++ {
		bar.Increment()
		bar.Postfix(" " + data[i][0])

		if (len(data[i]) > 2 && len(data[i][1]) == 0) || (len(data[i]) == 1) || All {

			var line = make([]string, Conf.Length)
			ip := data[i][0]
			// fmt.Println(ip)
			line[Conf.SaveOrder["ip"]] = ip

			for k := 1; k < Conf.Length; k++ {
				line[k] = ""
			}
			for _, field := range Conf.Fields {
				jsonbody, err := request(ip, field.Url)
				if err != nil {
					fmt.Println(err.Error())
					continue
				}

				for key, filter := range field.Filter {
					// fmt.Println(filter)
					_, ret := search(jsonbody, filter, 0)
					// data[i][]
					// fmt.Println(ret)
					if len(filter.Split) > 0 {
						aret := regexp.MustCompile(filter.Split).Split(ret, -1)
						for j := 0; j < len(aret); j++ {
							line[Conf.SaveOrder[key+"_"+strconv.Itoa(j)]] = line[Conf.SaveOrder[key+"_"+strconv.Itoa(j)]] + strings.TrimSpace(aret[j])
						}
					} else {
						line[Conf.SaveOrder[key]] = line[Conf.SaveOrder[key]] + strings.TrimSpace(ret)
					}
				}
			}
			// fmt.Println(line)
			linesave(line, ip)
			// fmt.Println(ip)
			// os.Exit(0)
		}
	}
	bar.FinishPrint("End")
}
开发者ID:sg3des,项目名称:whois,代码行数:49,代码来源:whois.go


示例20: main

func main() {
	targets := findTarget()
	bar = pb.StartNew(numOfSoldiers * numOfBattalions * len(targets))
	bar.Format("<.- >")
	var missionIssuedWg sync.WaitGroup
	for _, target := range targets {
		missionIssuedWg.Add(1)
		ht := hitRequest{}
		ht.Initialize()
		ht.url = target
		go deploy(ht, &missionIssuedWg)
	}
	missionIssuedWg.Wait()
	bar.FinishPrint("Victory!")
}
开发者ID:VarunBatraIT,项目名称:GoAttila,代码行数:15,代码来源:main.go



注:本文中的github.com/cheggaaa/pb.StartNew函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang pb.ProgressBar类代码示例发布时间:2022-05-23
下一篇:
Golang pb.New64函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap