3 ms·
Why the strong opinions about blocking? Go discourages, at least me, from doing non-blocking IO. I've heard that's a unix philosophy though. For example, io.
by 0xdeadbeefbabe 13y ago
Why the strong opinions about blocking? Go discourages, at least me, from doing non-blocking IO. I've heard that's a unix philosophy though. For example, io.Copy will block.
- jbooth 13y agoThere'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.