3 ms·
> one of the more common error cases is nil, closely followed by out of memory and zero division ... which in Go causes a panic just like every other language.
by tapirl 8y ago
> one of the more common error cases is nil, closely followed by out of memory and zero division ... which in Go causes a panic just like every other language.
Just FYI, out of memory is Go doesn't cause a panic. It is a fatal error which is unrecoverable and will crash the whole program.
BTW, your "More correct" version code is hilarious and very not professional.
- candiodari 8y agoIt's mostly there to illustrate how a basic attempt to create a correct way to use a simple system call would look like, with error, retry, actually writing the entire buffer and timeout would look like. I realize that it'd be lunacy to have this sort of code anywhere but in a library.