From f2df072f48cd6c740a8e3c7baf4312e36ff35340 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 22 Mar 2015 14:12:51 +0100 Subject: [PATCH] Progress: Don't panic for not running progress --- progress.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/progress.go b/progress.go index 9c4c47dc5..c84b91640 100644 --- a/progress.go +++ b/progress.go @@ -42,14 +42,10 @@ func NewProgress(d time.Duration) *Progress { // Start runs resets and runs the progress reporter. func (p *Progress) Start() { - if p == nil { + if p == nil || p.running { return } - if p.running { - panic("truing to reset a running Progress") - } - p.o = sync.Once{} p.cancel = make(chan struct{}) p.running = true @@ -135,14 +131,10 @@ func (p *Progress) Reset() { // Done closes the progress report. func (p *Progress) Done() { - if p == nil { + if p == nil || !p.running { return } - if !p.running { - panic("Done() called on non-running Progress") - } - if p.running { p.running = false p.o.Do(func() {