Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DrawTextFormatBytes ¶
DrawTextFormatBytes is a DrawTextFormatFunc that formats the progress and total into human-friendly byte formats.
Types ¶
type DrawFunc ¶
DrawFunc is the callback type for drawing progress.
func DrawTerminal ¶
DrawTerminal returns a DrawFunc that draws a progress bar to an io.Writer that is assumed to be a terminal (and therefore respects carriage returns).
func DrawTerminalf ¶
func DrawTerminalf(w io.Writer, f DrawTextFormatFunc) DrawFunc
DrawTerminalf returns a DrawFunc that draws a progress bar to an io.Writer that is formatted with the given formatting function.
type DrawTextFormatFunc ¶
DrawTextFormatFunc is a callback used by DrawFuncs that draw text in order to format the text into some more human friendly format.
func DrawTextFormatBar ¶
func DrawTextFormatBar(width int64) DrawTextFormatFunc
DrawTextFormatBar returns a DrawTextFormatFunc that draws a progress bar with the given width (in characters). This can be used in conjunction with another DrawTextFormatFunc to create a progress bar with bytes, for example:
bar := DrawTextFormatBar(20) func(progress, total int64) string { return fmt.Sprintf( "%s %s", bar(progress, total), DrawTextFormatBytes(progress, total)) }
type Reader ¶
type Reader struct { // Reader is the underlying reader to read from Reader io.Reader // Size is the total size of the data coming out of the reader. Size int64 // DrawFunc is the callback to invoke to draw the progress bar. By // default, this will be DrawTerminal(os.Stdout). // // DrawInterval is the minimum time to wait between reads to update the // progress bar. DrawFunc DrawFunc DrawInterval time.Duration // contains filtered or unexported fields }
Reader is an implementation of io.Reader that draws the progress of reading some data.