3 ms·
There's a robust syscall package that you can use to do whatever you want. And, under the hood, all of their net.Conn types use non-blocking i/o combined with
by jbooth 13y ago
There's a robust syscall package that you can use to do whatever you want.
And, under the hood, all of their net.Conn types use non-blocking i/o combined with the goroutine scheduler.
Basically, the philosophy is that rather than do it yourself, just write really simple blocking code using lots of really cheap goroutines, and the runtime non-blockifies it for you. If you really want nonblocking behavior, you can easily spin off a goroutine to do your i/o and then send on a channel or callback or whatever, and if you really want really nonblocking behavior, you can less easily use the syscall package to write your own conn type.