后端程序员之路 59、go uiprogress

gosuri/uiprogress: A go library to render progress bars in terminal applications
https://github.com/gosuri/uiprogress

依赖go-isatty,用于判断程序是在什么终端运行
https://github.com/mattn/go-isatty

依赖uilive,提供一个定时刷新的命令行输出
https://github.com/gosuri/uilive

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

  

原文地址:https://www.cnblogs.com/zapline/p/7753796.html