typo wich
This commit is contained in:
parent
893126b10b
commit
c1d7fa45eb
|
@ -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.
|
||||
|
||||
|
|
Loading…
Reference in New Issue