Uday Hiwarale
1 min readApr 27, 2020

--

Either use approach where error is always nil when n>0 and use error is always io.EOF when n=0.

In my examples, I mixed them both to avoid an extra Read call. You can avoid that if your business logic doesn’t allow it. If you are asking why I am not dealing with the error first, then this is just for demonstration. In real life, you should always check for errors first.

--

--

Responses (1)