Earlier quoted context omitted.
> Something I miss from the language … Does sound like you want to use channels, and break your logic into small independent parts. You will have one goroutine using blocking Read() in a loop and feeding data to some channel. When it's done, you write to another channel that exists only for signaling: defer { doneChannel and then in your other goroutine: for { select { case data := The only things shared here are the…
> but I think " And what looks even better: defer close(doneChannel) (it's also syntactically correct -- you ca't just have a defer block without a function invocation)
select {
case _, _ :=
It's so implicit that you pretty much have to add a comment to the effect of "this will trigger when the channel is closed", whereas the "case Also, I rather prefer the supervising goroutine to "own" the channel, so it should be the one to close it.> you ca't just have a defer block without a function invocation
Yeah, I was not thinking Go there for a moment. Should have been "defer func() { doneChannel <- true }".