4 ms·
A simpler example would be wishing to have a send with a timeout. A simple implementation in go would be like: func sendit(text string) bool { sel
by dfawcus 3y ago
A simpler example would be wishing to have a send with a timeout. A simple implementation in go would be like:
func sendit(text string) bool {
select {
case TxChan <- text:
case <-time.After(10 * time.Millisecond):
return false
}
return true
}
- Rochus 3y agoOk, that's a good example, thanks; unless we would allow a timer process to close TxChan there seems to be no other way than a mixed send/receive select.