Created
October 28, 2015 09:06
-
-
Save tucnak/eccdb53e7884084f5674 to your computer and use it in GitHub Desktop.
Nil errors are not always nil :)
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 | |
import "fmt" | |
type MagicError struct{} | |
func (MagicError) Error() string { | |
return "[Magic]" | |
} | |
func Generate() *MagicError { | |
return nil | |
} | |
func Test() error { | |
return Generate() | |
} | |
func main() { | |
if Test() != nil { | |
fmt.Println("Hello, Mr. Pike!") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment