You can use default part of select statement to do a non-blocking wait.

https://codeeval.dev/gist/aa8c428498bec53fdb448567c4b3f658

During first iteration of for loop select immediately ends up in default clause because channel is empty.

We send a value to the channel there so the next select will pick up the value from the channel.