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: 
It's a simple select:

```
select {
case s <- n:
    // Successful send.
case n := <- r:
    // Successful receive. Do something with n.
}

```
> 
> 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>