Hi. This is very simple program for testing about error type. I found that error type casting is something strange. I thing `err2` should be nil, but it is not nil. Someone can explain about this result?
https://play.golang.org/p/icjhpCCNe_ ---------- package main import ( "fmt" ) type MyError struct{} func (e MyError) Error() string { return "MyError" } func main() { var myError *MyError = nil if myError == nil { fmt.Println("myError is nil") } else { fmt.Println("myError is not nil") } var err1 error = error(nil) if err1 == nil { fmt.Println("err1 is nil") } else { fmt.Println("err1 is not nil") } var err2 error = error(myError) if err2 == nil { fmt.Println("err2 is nil") } else { fmt.Println("err2 is not nil") } } ----------- [RESULT] myError is nil err1 is nil err2 is not nil -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
