On Wed, Oct 6, 2021 at 2:35 PM Kamil Ziemian <kziemian...@gmail.com> wrote:
>
> I currently read about "io" package and again I read that "io.EOF" is not 
> treated as error, since it is what you expect to end file, which is almost 
> tautology. At the same time it satisfies error interface and is created 
> busing errors.New function.
>
> I understand why this is done, doing it other way would probably make serious 
> mess in the code, but pedantic said of me is unsettled by this. Does any 
> experience Gopher can give my advice how to think about situation when some 
> object satisfy interface, but it is exception that proves the rule? I should 
> just get used to it, or is it some better way of thinking?

I'm not sure what you mean when you say that io.EOF is not treated as
an error.  io.EOF is an error: it implements the error interface, and
is returned as the error value by methods such as Read.

Of course most programs that see an io.EOF error from Read do not want
to report that to the user, because it just means that they are at the
end of the file.  But that doesn't mean that it's not an error.  The
Read failed.  Every failure is reported via an error.  For the case in
which Read fails because it reaches the end of the file, the error
that it returns is io.EOF.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAOyqgcXVHAo7TEJrnuYwqnFXqSPp%3Dg0Os9Quv8r3qk-PjG4PZQ%40mail.gmail.com.

Reply via email to