Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
os: document form of returned errors #2383
As a newcomer to Go, I remember struggling with trying to find os.ENOENT, buried in a PathError, buried in an os.Error. This keeps coming up on the list too. The docs don't even say what type of errors Open or Stat might return: http://golang.org/pkg/os/#File.Open http://golang.org/pkg/os/#File.Stat (I remember first going on a mission to find a pretty printing function, eventually finding fmt %T and %#v) It might be worth calling out at least os.PathError there, and perhaps something like "If the file doesn't exist, the returned error will be of type *os.PathError, with a PathError.Error value of ENOENT".
For writing go-fuse I only need the errno error, since that is the only I can pass back. I ended up writing a function that tries to unpack the various errors and extract the error number. It's fragile though, since it depends on what error types the os package creates. I would very much welcome something that converts os errors to either an errno int (preferred) or a syscall.Errno error.
This issue was closed.