Timeline for How do I check a specific network error in Go?
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 24, 2014 at 8:07 | comment | added | prewett | I had a feeling that's what the answer would be... "Effective Go" is obviously necessary, but it has no answer to this question. I'm really disappointed in the poor documentation Go has, really among the worst I've used. And then, I discovered that if you want to find out if the error is a timeout, you appear to need to do "if netErr, ok := err.(net.Error); ok && netErr.Timeout()" which is completely inconsistent. Thanks for the other links, I'll read through them. | |
Jul 23, 2014 at 21:05 | comment | added | kostix | @prewett, the question of how to get there is more complicated... I assume most folks at some point read most of blog.golang.org articles (must read, really), the "Effective Go" document and other stuff like this go-to explanation of interfaces in Go, and then they have all the necessary parts of this "puzzle" in their brains. | |
Jul 23, 2014 at 21:01 | comment | added | kostix |
@prewett, well, I'm afraid that there's indeed no obvious connection, or, rather it is obvious to folks with certain mindset--let me explain. Go is very orthogonal and minimal, so really all the types in its stdlib which read bytes satisfy the io.Reader interface, and once you got to know this the idea the Read() method on a type implementing a TCP stream of bytes returns what io.Reader.Read() is defined to return upon encountering EOF is kind of self-evident.
|
|
Jul 23, 2014 at 8:36 | comment | added | prewett | To clarify, I assume that there was something in the documentation that I missed somewhere that would point me to look at the io package, even though I wasn't using any functions from io? | |
Jul 23, 2014 at 8:26 | vote | accept | prewett | ||
Jul 23, 2014 at 8:26 | comment | added | prewett | Ah, excellent! So how would I discover that the error I want to check for is io.EOF without asking StackOverflow? I assume there's something in the documentation that I missed? | |
Jul 22, 2014 at 10:24 | history | answered | kostix | CC BY-SA 3.0 |