Documentation ¶
Overview ¶
Package progress provides methods for monitoring the progress of io.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Copy ¶
Copy tracks progress of copied data from src to dst, progress events are sent to the return status channel, once completed the IsFinished routine will report true.
Example ¶
package main import ( "bytes" "os" "github.com/Bowery/progress" ) func main() { file, err := os.Open("/path/to/file") if err != nil { panic(err) } defer file.Close() stat, err := file.Stat() if err != nil { panic(err) } var buf bytes.Buffer progChan, errChan := progress.Copy(&buf, file, stat.Size()) isCopied := false for !isCopied { select { case status := <-progChan: if status.IsFinished() { isCopied = true break } case err := <-errChan: panic(err) } } }
Output:
Types ¶
type Status ¶
Status represents the copy progress. It contains the current progress and total size in bytes.
func (*Status) Completion ¶
Completion returns the current completion in the range [0, 1].
func (*Status) IsFinished ¶
IsFinished returns a boolean indicating whether the copy has completed.
Click to show internal directories.
Click to hide internal directories.