Compare commits
2 Commits
7be196e4c3
...
fd0fd8954a
| Author | SHA1 | Date | |
|---|---|---|---|
| fd0fd8954a | |||
| 628db14f59 |
@@ -56,16 +56,16 @@ func newProgressIndicatorWithClock(total int, description string, c clock) *Prog
|
||||
|
||||
func (p *ProgressIndicator) Update(current int) {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
|
||||
p.current = current
|
||||
now := p.clock.Now()
|
||||
|
||||
if now.Sub(p.lastUpdate) < 100*time.Millisecond {
|
||||
p.mu.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
p.lastUpdate = now
|
||||
p.mu.Unlock()
|
||||
p.display()
|
||||
}
|
||||
|
||||
|
||||
@@ -44,15 +44,14 @@ func captureOutput(fn func()) string {
|
||||
r, w, _ := os.Pipe()
|
||||
os.Stdout = w
|
||||
|
||||
defer func() {
|
||||
_ = w.Close()
|
||||
os.Stdout = old
|
||||
}()
|
||||
|
||||
fn()
|
||||
|
||||
_ = w.Close()
|
||||
os.Stdout = old
|
||||
|
||||
var buf bytes.Buffer
|
||||
_, _ = io.Copy(&buf, r)
|
||||
_ = r.Close()
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user