diff --git a/bar.go b/bar.go index d12b4fb..d070a2c 100644 --- a/bar.go +++ b/bar.go @@ -128,12 +128,12 @@ // Current returns the actual current. // If bar was stopped by Stop(), subsequent calls to Current will return -1 func (b *Bar) Current() int { - if !b.isDone() { - respCh := make(chan int) - b.currentReqCh <- respCh - return <-respCh - } - return -1 + if b.isDone() { + return -1 + } + respCh := make(chan int) + b.currentReqCh <- respCh + return <-respCh } // Stop stops rendering the bar @@ -163,12 +163,12 @@ // String returns the string representation of the bar func (b *Bar) String() string { - if !b.isDone() { - respCh := make(chan []byte) - b.redrawReqCh <- respCh - return string(<-respCh) - } - return string(b.lastFrame) + if b.isDone() { + return string(b.lastFrame) + } + respCh := make(chan []byte) + b.redrawReqCh <- respCh + return string(<-respCh) } func (b *Bar) server(wg *sync.WaitGroup, total int) { @@ -272,12 +272,12 @@ } func (b *Bar) status() int { - if !b.isDone() { - respCh := make(chan int) - b.statusReqCh <- respCh - return <-respCh - } - return b.lastStatus + if b.isDone() { + return b.lastStatus + } + respCh := make(chan int) + b.statusReqCh <- respCh + return <-respCh } // SortableBarSlice satisfies sort interface