diff --git a/example/multi/multi.go b/example/multi/multi.go index cae0e03..1216aa2 100644 --- a/example/multi/multi.go +++ b/example/multi/multi.go @@ -3,25 +3,22 @@ import ( "fmt" "math/rand" - "runtime" "time" "github.com/vbauerster/uiprogress" ) const ( - maxBlockSize = 14 + maxBlockSize = 12 ) func main() { - runtime.GOMAXPROCS(runtime.NumCPU()) - decor := func(s *uiprogress.Statistics) string { str := fmt.Sprintf("%d/%d", s.Completed, s.Total) return fmt.Sprintf("%-7s", str) } - p := uiprogress.New() + p := uiprogress.New().RefreshRate(80 * time.Millisecond) bar1 := p.AddBar(50).AppendETA().PrependFunc(decor) go func() { diff --git a/progress.go b/progress.go index 864c4c5..65e41cf 100644 --- a/progress.go +++ b/progress.go @@ -55,6 +55,16 @@ return p } +// SetOut sets underlying writer of progress +// default is os.Stdout +func (p *progress) SetOut(w io.Writer) *progress { + if w == nil { + return p + } + p.out = w + return p +} + // AddBar creates a new progress bar and adds to the container func (p *progress) AddBar(total int) *Bar { p.wg.Add(1) @@ -75,18 +85,6 @@ p.interval <- d return p } - -// SetOut sets underlying writer of progress -// default is os.Stdout -func (p *progress) SetOut(w io.Writer) *progress { - p.out = w - return p -} - -// Bypass returns a writer which allows non-buffered data to be written to the underlying output -// func (p *progress) Bypass() io.Writer { -// return p.lw.Bypass() -// } // WaitAndStop stops listening func (p *progress) WaitAndStop() {