diff --git a/bar.go b/bar.go index dd1d967..ed46f69 100644 --- a/bar.go +++ b/bar.go @@ -36,7 +36,7 @@ ops chan func(*bState) // following are used after b.done is receiveable - cacheState bState + cacheState *bState once sync.Once } @@ -80,7 +80,7 @@ total = time.Now().Unix() } - s := bState{ + s := &bState{ id: ID, total: total, etaAlpha: etaAlpha, @@ -88,7 +88,7 @@ } for _, opt := range options { - opt(&s) + opt(s) } s.bufP = bytes.NewBuffer(make([]byte, 0, s.width/2)) @@ -266,7 +266,7 @@ close(b.quit) } -func (b *Bar) server(s bState, wg *sync.WaitGroup, cancel <-chan struct{}) { +func (b *Bar) server(s *bState, wg *sync.WaitGroup, cancel <-chan struct{}) { defer func() { b.cacheState = s close(b.done) @@ -276,7 +276,7 @@ for { select { case op := <-b.ops: - op(&s) + op(s) case <-cancel: s.aborted = true cancel = nil