当前位置: 首页>>代码示例>>Golang>>正文


Golang uiprogress.Start函数代码示例

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


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

示例1: generateGIF

func generateGIF(filenames []string, outPath string) error {
	fmt.Printf("Generating GIF in %s\n", outPath)
	uiprogress.Start()
	bar := uiprogress.AddBar(len(filenames)).AppendCompleted()
	anim := gif.GIF{LoopCount: len(filenames)}
	for _, filename := range filenames {
		reader, err := os.Open(filename)
		if err != nil {
			return err
		}
		defer reader.Close()
		img, _, err := image.Decode(reader)
		if err != nil {
			return err
		}
		bounds := img.Bounds()
		drawer := draw.FloydSteinberg
		palettedImg := image.NewPaletted(bounds, palette.Plan9)
		drawer.Draw(palettedImg, bounds, img, image.ZP)
		anim.Image = append(anim.Image, palettedImg)
		anim.Delay = append(anim.Delay, *delay)
		bar.Incr()
	}
	file, err := os.Create(outPath)
	defer file.Close()
	if err != nil {
		return err
	}
	encodeErr := gif.EncodeAll(file, &anim)
	if encodeErr != nil {
		return encodeErr
	}
	return nil
}
开发者ID:castillobg,项目名称:gipher,代码行数:34,代码来源:main.go

示例2: main

func main() {
	log.SetFlags(log.LstdFlags | log.Lshortfile)
	tagflag.Parse(&opts, tagflag.SkipBadTypes())
	clientConfig := opts.Config
	if opts.Mmap {
		clientConfig.TorrentDataOpener = func(info *metainfo.Info) torrent.Data {
			ret, err := mmap.TorrentData(info, "")
			if err != nil {
				log.Fatalf("error opening torrent data for %q: %s", info.Name, err)
			}
			return ret
		}
	}

	client, err := torrent.NewClient(&clientConfig)
	if err != nil {
		log.Fatalf("error creating client: %s", err)
	}
	defer client.Close()
	http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
		client.WriteStatus(w)
	})
	uiprogress.Start()
	addTorrents(client)
	if client.WaitAll() {
		log.Print("downloaded ALL the torrents")
	} else {
		log.Fatal("y u no complete torrents?!")
	}
	if opts.Seed {
		select {}
	}
}
开发者ID:jaswinder-singh,项目名称:torrentsaga,代码行数:33,代码来源:main.go

示例3: main

func main() {
	log.SetFlags(log.LstdFlags | log.Lshortfile)
	tagflag.Parse(&opts, tagflag.SkipBadTypes())
	clientConfig := opts.Config
	if opts.Mmap {
		clientConfig.DefaultStorage = storage.NewMMap("")
	}

	client, err := torrent.NewClient(&clientConfig)
	if err != nil {
		log.Fatalf("error creating client: %s", err)
	}
	defer client.Close()
	http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
		client.WriteStatus(w)
	})
	uiprogress.Start()
	addTorrents(client)
	if client.WaitAll() {
		log.Print("downloaded ALL the torrents")
	} else {
		log.Fatal("y u no complete torrents?!")
	}
	if opts.Seed {
		select {}
	}
}
开发者ID:CaptainIlu,项目名称:cloud-torrent,代码行数:27,代码来源:main.go

示例4: main

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 := uiprogress.AddBar(count).AppendCompleted().PrependElapsed()
	bar.PrependFunc(func(b *uiprogress.Bar) string {
		return fmt.Sprintf("Task (%d/%d)", b.Current(), count)
	})

	uiprogress.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()
	uiprogress.Stop()
}
开发者ID:louisyoo,项目名称:uiprogress,代码行数:26,代码来源:incr.go

示例5: NewPomodoro

func NewPomodoro() *Pomodoro {
	pomodoro := Pomodoro{
		done: make(chan struct{}, 0),
	}

	sig := make(chan os.Signal, 1)
	signal.Notify(sig, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)

	go func() {
		for {
			select {
			case <-pomodoro.done:
			case <-sig:
				if pomodoro.running {
					pomodoro.Stop()
				} else {
					os.Exit(0)
				}
			}
		}
	}()

	uiprogress.Start()

	return &pomodoro
}
开发者ID:VojtechVitek,项目名称:pomodoro,代码行数:26,代码来源:main.go

示例6: main

func main() {
	log.SetFlags(log.LstdFlags | log.Lshortfile)
	tagflag.Parse(&flags)
	var clientConfig torrent.Config
	if flags.Mmap {
		clientConfig.DefaultStorage = storage.NewMMap("")
	}
	if flags.Addr != nil {
		clientConfig.ListenAddr = flags.Addr.String()
	}

	client, err := torrent.NewClient(&clientConfig)
	if err != nil {
		log.Fatalf("error creating client: %s", err)
	}
	defer client.Close()
	// Write status on the root path on the default HTTP muxer. This will be
	// bound to localhost somewhere if GOPPROF is set, thanks to the envpprof
	// import.
	http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
		client.WriteStatus(w)
	})
	uiprogress.Start()
	addTorrents(client)
	if client.WaitAll() {
		log.Print("downloaded ALL the torrents")
	} else {
		log.Fatal("y u no complete torrents?!")
	}
	if flags.Seed {
		select {}
	}
}
开发者ID:ymonk,项目名称:torrent,代码行数:33,代码来源:main.go

示例7: Save

// Save method persist (save or update) the chain on the disk
func (c *Chain) Save() {
	var cn = c.collection
	if c.collection == "" {
		cn = timeName()
		c.collection = cn
	}

	sess, coll := model.Connect(cn)
	defer sess.Close()

	ks := c.Keys()
	sort.Strings(ks)

	var wg sync.WaitGroup
	var workForce = 5
	ch := make(chan model.NewNodeInfo, workForce)

	for i := 0; i < workForce; i++ {
		wg.Add(1)
		go func() {
			defer wg.Done()
			var ni model.NewNodeInfo
			var more bool

			for {
				ni, more = <-ch
				if more {
					model.NewNode(ni).Save(coll)
				} else {
					return
				}
			}
		}()
	}

	count := len(ks)
	bar := uiprogress.AddBar(count)
	bar.AppendCompleted()
	bar.PrependElapsed()
	bar.PrependFunc(func(b *uiprogress.Bar) string {
		return fmt.Sprintf("Node (%d/%d)", b.Current(), count)
	})

	uiprogress.Start()
	for _, x := range ks {
		ch <- model.NewNodeInfo{x, c.chain[x]}

		bar.Incr()
	}

	uiprogress.Stop()
	close(ch)
	wg.Wait()
}
开发者ID:zeroed,项目名称:markovianomatic,代码行数:55,代码来源:markovianomatic.go

示例8: Execute

func (o *Get) Execute(args []string) error {
	client, err := Client()
	if err != nil {
		return err
	}

	bucket, err := client.Bucket(opts.Bucket)
	if err != nil {
		return err
	}
	if bucket == nil {
		return errors.New("Bucket not found: " + opts.Bucket)
	}

	uiprogress.Start()
	pool := make(chan bool, o.Threads)
	group := sync.WaitGroup{}
	var downloadError error

	for _, file := range args {
		// TODO handle wildcards

		fileInfo, reader, err := bucket.DownloadFileByName(file)
		if err != nil {
			downloadError = err
			break
		}

		// Get a ticket to process a download
		pool <- true

		if downloadError != nil {
			break
		}

		// Start next parallel download
		group.Add(1)
		go func(fileInfo *backblaze.File, reader io.ReadCloser, path string) {
			err := download(fileInfo, reader, path)
			if err != nil {
				fmt.Println(err)
				downloadError = err
			}

			// Allow next entry into pool
			group.Done()
			<-pool
		}(fileInfo, reader, file)
	}

	group.Wait()

	return downloadError
}
开发者ID:kothar,项目名称:go-backblaze-fork,代码行数:54,代码来源:get.go

示例9: Example

func Example() {
	uiprogress.Start()            // start rendering
	bar := uiprogress.AddBar(100) // Add a new bar

	// optionally, append and prepend completion and elapsed time
	bar.AppendCompleted()
	bar.PrependElapsed()

	for bar.Incr() {
		time.Sleep(time.Millisecond * 20)
	}
}
开发者ID:hjortron,项目名称:uiprogress,代码行数:12,代码来源:example_test.go

示例10: Generate

func Generate() {
	cfg := Conf{}
	var fId, mail, pass, name, hueser string
	var speed time.Duration

	reader := bufio.NewReader(os.Stdin)

	fmt.Println("Your facebook id:")
	fmt.Scanln(&fId)
	cfg.UserId = fId

	fmt.Println("Your facebook mail:")
	fmt.Scanln(&mail)
	cfg.Mail = mail

	fmt.Println("Your facebook password:")
	pass, err := reader.ReadString('\n')
	checkErr(err)
	cfg.Pass = pass[:len(pass)-2]

	bridges, err := hue.FindBridges()
	checkErr(err)
	bridge := bridges[0]

	fmt.Println("Please authorize this program, by linking it on your bridge now; you've got 15 seconds.")

	uiprogress.Start()
	bar := uiprogress.AddBar(15000 / 100).AppendCompleted().PrependElapsed()
	for bar.Incr() {
		time.Sleep(100 * time.Millisecond)
	}

	hueser, err = bridge.CreateUser(mail)
	checkErr(err)
	cfg.Hueser = hueser

	fmt.Println("Name of your light:")
	name, err = reader.ReadString('\n')
	checkErr(err)
	cfg.Name = name[:len(name)-2]

	fmt.Println("Blink speed of the light:")
	fmt.Scanln(&speed)
	cfg.Speed = speed

	byteArr, _ := json.Marshal(cfg)
	file, err := os.Create("config.json")
	checkErr(err)

	_, err = file.Write(byteArr)
	checkErr(err)
}
开发者ID:Mobilpadde,项目名称:FaceUp,代码行数:52,代码来源:conf.go

示例11: main

func main() {
	fmt.Println("apps: deployment started: app1, app2")
	uiprogress.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")
}
开发者ID:pranavcode,项目名称:uiprogress,代码行数:13,代码来源:full.go

示例12: main

func main() {
	uiprogress.Start() // start rendering

	bar := uiprogress.AddBar(100) // Add a new bar

	// optionally, append and prepend completion and elapsed time
	bar.AppendCompleted()
	bar.PrependElapsed()

	for i := 1; i <= bar.Total; i++ {
		bar.Set(i)
		time.Sleep(time.Millisecond * 10)
	}
}
开发者ID:pranavcode,项目名称:uiprogress,代码行数:14,代码来源:simple.go

示例13: performDeploy

func performDeploy(args []string) error {
	if len(args) != 1 {
		return errors.New("deploy takes only 1 argument - Marathon's application definition file")
	}
	path := args[0]
	renderedConfig, err := appconfig.Render(environment, path)
	if dryRun {
		fmt.Println("Rendered app specification")
		fmt.Println(renderedConfig)
		return err
	}

	var configMap map[string]interface{}
	util.JsonDecode(renderedConfig, &configMap)
	appName := configMap["id"].(string)

	fmt.Println("Deploying " + appName + " from " + path)
	deployment, err := marathon.Deploy(appName, renderedConfig, force)
	if err != nil {
		return err
	}

	// Do fancy UI updates on the screen
	uiprogress.Start()
	defer uiprogress.Stop()
	bar := uiprogress.AddBar(timeoutInSeconds + 1)
	bar.AppendCompleted()
	bar.PrependElapsed()
	bar.PrependFunc(func(b *uiprogress.Bar) string {
		return appName + " deploying"
	})

	for bar.Incr() {
		time.Sleep(time.Millisecond * 1000)
		if bar.Current()%15 == 0 { // check the deployment stauts only every 15 seconds
			stillDeploying, err := marathon.IsStillDeploying(deployment)
			if err != nil {
				return err
			}
			if !stillDeploying {
				bar.Set(timeoutInSeconds)
				time.Sleep(time.Millisecond * 20) // wait for a few ms to refresh the output
				fmt.Println("Deployment completed")
				return nil
			}
		}
	}

	return errors.New("[ERROR] App deployment timed out. Check Marathon UI for more details")
}
开发者ID:ashwanthkumar,项目名称:marathonctl,代码行数:50,代码来源:deploy.go

示例14: main

func main() {
	fmt.Println("apps: deployment started...")
	uiprogress.Start()

	var wg sync.WaitGroup
	apps := 1
	for apps < 4 {
		wg.Add(1)
		go deploy("app "+strconv.Itoa(apps), &wg)
		apps += apps
	}
	wg.Wait()

	fmt.Println("apps: successfully deployed...")
}
开发者ID:Chubik,项目名称:testgolang,代码行数:15,代码来源:test2.go

示例15: Execute

// Execute the put command
func (o *Put) Execute(args []string) error {
	client, err := Client()
	if err != nil {
		return err
	}

	bucket, err := client.Bucket(opts.Bucket)
	if err != nil {
		return err
	}
	if bucket == nil {
		return errors.New("Bucket not found: " + opts.Bucket)
	}

	uiprogress.Start()
	tasks := make(chan string, o.Threads)
	group := sync.WaitGroup{}

	// Create workers
	for i := 0; i < o.Threads; i++ {
		group.Add(1)
		go func() {
			for file := range tasks {
				_, err := upload(bucket, file, o.Meta)
				if err != nil {
					fmt.Println(err)
				}

				// TODO handle termination on error
			}
			group.Done()
		}()
	}

	for _, file := range args {
		tasks <- file
	}
	close(tasks)

	group.Wait()

	return nil
}
开发者ID:kothar,项目名称:go-backblaze,代码行数:44,代码来源:put.go


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