您当前的位置: 首页 >  ui

彭世瑜

暂无认证

  • 3浏览

    0关注

    2791博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Golang:uiprogress在终端实现进度条功能

彭世瑜 发布时间:2022-09-09 10:02:57 ,浏览量:3

A Go library to render progress bars in terminal applications. It provides a set of flexible features with a customizable API.

译文:用于在终端应用程序中呈现进度条的Go库。它提供了一组灵活的功能和可定制的API。

文档

  • https://pkg.go.dev/github.com/gosuri/uiprogress
  • https://github.com/gosuri/uiprogress

安装

go get github.com/gosuri/uiprogress

示例

package main

import (
	"time"

	"github.com/gosuri/uiprogress"
)

func main() {
	uiprogress.Start()            // 开始
	bar := uiprogress.AddBar(100) // 添加一个新的进度条

	// 可选,添加完成进度
	bar.AppendCompleted()
	// 可选,添加耗费时间
	bar.PrependElapsed()
	
	// 增加进度条的值 
	for bar.Incr() {
		time.Sleep(time.Millisecond * 20)
	}
}

效果 在这里插入图片描述

参考 「Go工具箱」推荐一个实现进度条功能的工具:uiprogress

关注
打赏
1665367115
查看更多评论
立即登录/注册

微信扫码登录

0.0741s