3 ms·
You can select on the read and an time.After channel which "interrupts" the select for a timeout.
by mentat 10y ago
You can select on the read and an time.After channel which "interrupts" the select for a timeout.
- lobster_johnson 10y agoYou can't select on a read, though. select{} only works on channels. You can run the read in a separate goroutine, but that doesn't stop the read from happening.
- tptacek 10y agoYou can't use the language "select", but you can call the select(2) system call.
- lobster_johnson 10y agoIndeed, someone already pointed this out: https://news.ycombinator.com/item?id=13332847 https://news.ycombinator.com/item?id=13332847.