My code looks like this:
outChannel := make(chan struct{})
...
for out := range outChannel {
...
}
I have a producer writing to outChannel
and would like to timeout on reading from it (if overall processing takes more than XX seconds).
What would be the proper way to do so?
As I've only seen construct (at: https://github.com/golang/go/wiki/Timeouts) using select
with multiple case
s reading from the channels, however, this seems not applicable once using range
.