Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ProgressOption ¶
type ProgressOption func(*ProgressWriter)
ProgressOption configures the behaviour of ProgressWriter.
func WithFrequency ¶
func WithFrequency(freq time.Duration) ProgressOption
WithFrequency sets how often updates are printed.
func WithMessage ¶
func WithMessage(msg string) ProgressOption
WithMessage sets the status prefix shown before percentage/KiB.
func WithOutput ¶
func WithOutput(w io.Writer) ProgressOption
WithOutput sets the destination writer (defaults to os.Stderr).
type ProgressWriter ¶
type ProgressWriter struct {
// contains filtered or unexported fields
}
ProgressWriter is an io.Writer that prints a simple progress bar. It is safe to use with io.TeeReader.
pw := common.NewProgressWriter(resp.ContentLength, common.WithMessage("Downloading...")) io.Copy(dst, io.TeeReader(src, pw))
func NewProgressWriter ¶
func NewProgressWriter(contentLen int64, opts ...ProgressOption) *ProgressWriter
NewProgressWriter returns a configured ProgressWriter.
Click to show internal directories.
Click to hide internal directories.