lionkov / go9p

Package for implementing clients and servers of the 9P and 9P2000 distributed resource protocols in Go.
Other
20 stars 7 forks source link

ls.go Error "" #17

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
marko@ributtalo $ ./ls -addr="127.0.0.1:5645" /                                 

2011/06/06 18:19:22 Error

(I use ufs.go as 9p server, and it works fine with 9mount on linux)

"ReadDir(0)" returns the error, and the error has an empty string message.

Original issue reported on code.google.com by mmikuli...@gmail.com on 6 Jun 2011 at 4:24

GoogleCodeExporter commented 9 years ago
I think I found two issues introduced by fixing issue #13:

 1. client ReadDir should treat os.EOF as indication of stream termination, not erro
 2. subtle "err != nil" always true when an err variable of type os.Error gets assigned with a *Error: even if the *Error value is nil, the os.Error value is never nil 

patch attached

PS: about point 2:

I'm new to go and I find it weird but, yes, it makes sense. Consider:

func main() {
    var x *int = nil
    var t interface{} = x

    fmt.Printf("%t\n", t == nil) // prints "false"
}

This is because an interface value has to have a "zero" value, and it's nil. If 
you assign a pointer which implements that interface, that pointer can point 
somewhere or be nil, it doesn't matter, it's a valid pointer; and if you assign 
this pointer to the interface value, that interface value now has a value which 
is not nil.

Original comment by mmikuli...@gmail.com on 6 Jun 2011 at 8:51

Attachments:

GoogleCodeExporter commented 9 years ago
(for educational purposes I expanded a little bit the causes of this issue 
here: http://www.coldcode.net/2011/06/golang-interface-is-not-nil-even-if.html)

Original comment by mmikuli...@gmail.com on 6 Jun 2011 at 9:13

GoogleCodeExporter commented 9 years ago
Fixed

Original comment by lion...@gmail.com on 13 Jun 2011 at 3:46