Question: Suppose I have a buffered send and unbuffered receive channel:

```
s := make(chan<- int, 5)
r := make(<-chan int)

```

Is it possible to `select` on them both, so that `r` will be selected if it has anything to read, and `s` will be selected if it is not full? Something equivalent to this, but not using 100% CPU:

```
for {
    if len(s) < cap(s) {
        // Send something
    }
    if len(r) > 0 {
        // Receive something
    }
}

```

Note that I want to decide what to send at the time that I send it, not earlier.

### Edit

This question is basically equivalent to "Can I block until a channel is ready-to-send, *without* sending anything?"

Answer: 
Instead of sending the value directly, you could send an object which can compute the value. Then you can detect when the object is sent, and then compute. You can use sync.Once to make sure the computation is done once, and gate access to the result. This avoids using Sleeps.

Something like this: <https://play.golang.org/p/oL2HA2jl91>
> 
> Can I block until a channel is ready-to-send, without sending anything?
> 
> 
> 

Not with primitive go channels. You could probably manage to pull something together using the `SharedBuffer` type in my channels library, but even that is complicated and it uses a great deal of reflection under the covers.

<https://godoc.org/github.com/eapache/channels#SharedBuffer>