diff --git a/bar.go b/bar.go index 3e0943b..63ca61c 100644 --- a/bar.go +++ b/bar.go @@ -41,10 +41,6 @@ } type ( - refill struct { - char rune - till int64 - } state struct { id int width int @@ -68,6 +64,10 @@ bufP, bufB, bufA *bytes.Buffer panic string } + refill struct { + char rune + till int64 + } writeBuf struct { buf []byte completeAfterFlush bool diff --git a/progress.go b/progress.go index 6e85ab1..be3413b 100644 --- a/progress.go +++ b/progress.go @@ -114,7 +114,8 @@ // RemoveBar removes bar at any time. func (p *Progress) RemoveBar(b *Bar) bool { result := make(chan bool, 1) - op := func(c *pConf) { + select { + case p.ops <- func(c *pConf) { var ok bool for i, bar := range c.bars { if bar == b { @@ -125,9 +126,7 @@ } } result <- ok - } - select { - case p.ops <- op: + }: return <-result case <-p.quit: return false @@ -137,11 +136,10 @@ // BarCount returns bars count func (p *Progress) BarCount() int { result := make(chan int, 1) - op := func(c *pConf) { + select { + case p.ops <- func(c *pConf) { result <- len(c.bars) - } - select { - case p.ops <- op: + }: return <-result case <-p.quit: return 0