progress

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2019 License: Unlicense Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TrackProgress

func TrackProgress(p ProgressReporter, total int, done chan<- bool)

TrackProgress monitors the passed ProgressReporter and draws a progress bar to stdout based on expected total. Due to a 1 second resolution it uses a channel to wake the parent goroutine once it finishes.

Types

type ProgressReporter

type ProgressReporter interface {
	// GetProgress returns the totalProgress of the r/w interface
	GetProgress() int
}

ProgressReporter is an interface implemented by progress-tracking readers and writers

type Reader

type Reader struct {
	// Reader is the underlying io.Reader to which all read calls are proxied.
	io.Reader
	// contains filtered or unexported fields
}

Reader extends io.Reader interface with a byte counter

func NewReader

func NewReader(r io.Reader) Reader

NewReader returns a new reader with progress reporting capability.

func (*Reader) GetProgress

func (r *Reader) GetProgress() int

GetProgress returns the total number of bytes read.

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

Read proxies all reads while tracking the totalProgress.

type Writer

type Writer struct {
	// Writer is the underlying io.Writer to which all read calls are proxied.
	io.Writer
	// contains filtered or unexported fields
}

Writer extends io.Writer interface with a byte counter

func NewWriter

func NewWriter(w io.Writer) Writer

NewWriter returns a new writer with progress reporting capability.

func (*Writer) GetProgress

func (w *Writer) GetProgress() int

GetProgress returns the total number of bytes written.

func (*Writer) Write

func (w *Writer) Write(p []byte) (n int, err error)

Write proxies all writes while tracking the totalProgress.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL