Hi,
I have been learning the Go language the past couple of days. I am
struggling to figure out how to properly handle several standard library
error conditions and where to find a list of the possible error
conditions that each function can return.
On Unix/Linux/BSD the syscall and libc manual pages always list all the
possible error conditions for each function. The Go documentation
completely lacks this information unless I am missing something.
Right now I am implementing some code where I do DNS lookups and need to
detect "host not found" error condition and handle it specially. How do
I do this? I would like to do something like the following example:
addrs, err := net.LookupHost(hostname)
if err == net.ErrHostNotFound {
// host was not found, do something
...
} else if err != nil {
// handle other errors
fmt.Writeln("Error:", err)
return
}
Another error that I need to catch is a disk full situation (ENOSPC in
traditional Unix errno terms) when writing to a file with fmt.Fprint().
What should I be looking for in this case? "godoc io" documents a few
I/O error conditions (such as io.EOF) but the list seems to be very
limited.
I hope I am missing something obvious... I would appreciate if someone
could point me to the right direction.
--
Janne Snabb / EPIPE Communications
sn...@epipe.com -
http://epipe.com/