How can I do something like the following?:
func foo(input <-chan char, output chan<- string) {
var c char
var ok bool
for {
if ThereAreValuesBufferedIn(input) {
c, ok = <-input
} else {
output <- "update message"
c, ok = <-input
}
DoSomethingWith(c, ok)
}
}
Basically, I want to check if there are buffered values in the chan so that if there aren't, I could send an update message before the thread is blocked.