Skip to content

Instantly share code, notes, and snippets.

@cloudhead
Created April 5, 2017 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cloudhead/9e5a55413b17db5070277081d2b2ddec to your computer and use it in GitHub Desktop.
Save cloudhead/9e5a55413b17db5070277081d2b2ddec to your computer and use it in GitHub Desktop.
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