diff --git a/progress.go b/progress.go index 4fa15b2..ebd9089 100644 --- a/progress.go +++ b/progress.go @@ -322,8 +322,9 @@ ws.listen[i] = make(chan int, numBars) ws.result[i] = make(chan int, numBars) } - for i, listenCh := range ws.listen { + for i := 0; i < numColumn; i++ { go func(listenCh <-chan int, resultCh chan<- int) { + defer close(resultCh) widths := make([]int, 0, numBars) loop: for { @@ -341,13 +342,12 @@ for i := 0; i < numBars; i++ { resultCh <- result } - close(resultCh) - }(listenCh, ws.result[i]) + }(ws.listen[i], ws.result[i]) } return ws } -func drawer(ibars <-chan indexedBar, c chan<- indexedBarBuffer, prependWs, appendWs *widthSync) { +func drawer(ibars <-chan indexedBar, ibbCh chan<- indexedBarBuffer, prependWs, appendWs *widthSync) { for b := range ibars { buf := b.bar.bytes(b.termWidth, prependWs, appendWs) buf = append(buf, '\n')