Fix silence import: also wait for the error collection goroutine to finish
As noticed by George Robinson the error collection goroutine in silence import is also not waited for, so we may get an incorrect count when we exit. This adds a done channel for that goroutine, and checks that the error count is correct with a new test.
Signed-off-by: Guido Trotter [email protected]
Looks ok, but I said that with the previous one and now I'm unsure :D
I was wondering if the cleanupDone could be done with https://pkg.go.dev/sync#Once
eg
var once sync.Once
closeChannels := func() {
once.Do(func() {
close(silencec)
wg.Wait()
close(errc)
<-errDone
close(errDone)
})
}
Looks ok, but I said that with the previous one and now I'm unsure :D
I was wondering if the cleanupDone could be done with https://pkg.go.dev/sync#Once
eg
var once sync.Once closeChannels := func() { once.Do(func() { close(silencec) wg.Wait() close(errc) <-errDone close(errDone) }) }
Done, thanks for the suggestion!