Created
April 5, 2017 13:50
-
-
Save cloudhead/9e5a55413b17db5070277081d2b2ddec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
type Error struct { | |
Err error | |
} | |
func (e *Error) Error() string { | |
return e.Err.Error() | |
} | |
func foo() error { | |
return nil | |
} | |
func bar() *Error { | |
return nil | |
} | |
func main() { | |
err := foo() | |
println(err == nil) // true | |
err = bar() | |
println(err == nil) // false! | |
e := bar() | |
println(e == nil) // true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment