利用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 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!