diff --git a/progressbar.go b/progressbar.go index dbdeb0a..1d60be3 100644 --- a/progressbar.go +++ b/progressbar.go @@ -494,10 +494,7 @@ func (p *ProgressBar) Reset() { // Finish will fill the bar to full func (p *ProgressBar) Finish() error { - p.lock.Lock() - p.state.currentNum = p.config.max - p.lock.Unlock() - return p.Add(0) + return p.Set64(p.config.max) } // Exit will exit the bar to keep current state diff --git a/progressbar_test.go b/progressbar_test.go index ce780e8..cf46bec 100644 --- a/progressbar_test.go +++ b/progressbar_test.go @@ -94,10 +94,12 @@ func ExampleOptionClearOnFinish() { } func ExampleProgressBar_Finish() { - bar := NewOptions(100, OptionSetWidth(10)) + bar := NewOptions(100, OptionSetWidth(10), OptionShowCount(), OptionShowBytes(true), OptionShowIts()) + bar.Reset() + time.Sleep(1 * time.Second) bar.Finish() // Output: - // 100% |██████████| + // 100% |██████████| (100/100 B, 100 B/s, 100 it/s) } func Example_xOutOfY() {