typo wich

This commit is contained in:
Wouter Groeneveld 2024-03-26 12:03:08 +01:00
parent 893126b10b
commit c1d7fa45eb
1 changed files with 1 additions and 1 deletions

View File

@ -50,7 +50,7 @@ func ToDoneInterface(done <-chan struct{}) <-chan interface{} {
}
```
The `defer close()` seems to close well, but it's on the wrong channel. The `select{}` will wait until it received a signal from `done`: that's either when something is sent or when a `close()` has been called (a `nil` value). So, the Goroutine closes the channel **after** the first received `struct{}` on the passed `done` channel. If we pass the same channel multiple times---which we do---and that channel lives longer than is the case wich `ctx.Done()`---which it is---this Goroutine will leak.
The `defer close()` seems to close well, but it's on the wrong channel. The `select{}` will wait until it received a signal from `done`: that's either when something is sent or when a `close()` has been called (a `nil` value). So, the Goroutine closes the channel **after** the first received `struct{}` on the passed `done` channel. If we pass the same channel multiple times---which we do---and that channel lives longer than is the case which `ctx.Done()`---which it is---this Goroutine will leak.
I don't know if that all makes sense if you're not familiar with Go, or even if you are. I know I had to stare at the above code block for a good hour and its usage context (got it, `Context`? Go-joke!) before realizing something wasn't as it was supposed to be here.