0
点赞
收藏
分享

微信扫一扫

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


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)
}
}

效果

Golang:uiprogress在终端实现进度条功能_开发语言

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


举报

相关推荐

0 条评论