Hacker News new | past | comments | ask | show | jobs | submit login

I'm not that great in golang but I don't understand why you "must" not consult the error first in this situation:

>First they must record the number of bytes read into the buffer, reslice the buffer, process that data, and only then, consult the error.




I'm not that familiar with io.Reader but it sounds like you might get back both some bytes and also a read error. If you handle the read error before handling the bytes by, say, "return err", then you lose the bytes you got before the error. Losing those bytes could be bad.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: