Konstantin Khomoutov
unread,Jun 9, 2015, 12:26:53 PM6/9/15Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Rafa Perez, Konstantin Khomoutov, Dave Cheney, golan...@googlegroups.com
On Tue, 9 Jun 2015 11:50:44 -0400
> What I'm questioning myself at this point is best way to handle this:
>
> > ...
> > err := errors.New("EOF")
> > if err != nil {
> > ...
>
>
> Since there will be valid responses that will have *err != nil*... I
> can't think about an idiomatic way to do this at this point.
I don't understand this bit.
All the code in the standard library (and the code in sensible
3rd-party packages) uses *the value* io.EOF exported by the standard
package "io" [1] to signal EOF condition, so basically your check should
be the plain comparison of the error value returned by the Read() call
on the response's body with the value io.EOF.
Note that godoc does only document exported stuff, and everything in Go
which starts with a capital letter is exported.
In other words, that io.EOF thing is "stable" in that you can just
compare the errors you get with it.
1.
http://golang.org/pkg/io/#pkg-variables