利用io.Reader/Writers实现进度条的Go(golang)包:ioprogress
ioprogress是一个Go (golang)库利用 io.Reader 和 io.Writer 来绘制进度条。它主要用在CLI 应用中。
用法
Here is an example of outputting a basic progress bar to the CLI as we're "downloading" from some other io.Reader
(perhaps from a network connection):
// Imagine this came from some external source, such as a network connection, // and that we have the full size of it, such as from a Content-Length HTTP // header. var r io.Reader // Create the progress reader progressR := &ioprogress.Reader{ Reader: r, Size: rSize, } // Copy all of the reader to some local file f. As it copies, the // progressR will write progress to the terminal on os.Stdout. This is // customizable. io.Copy(f, progressR)
本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!