Last active
October 3, 2021 09:25
-
-
Save mkock/704878167933eccd155a4054766b5987 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| type myError struct{} | |
| func (m *myError) Error() string { | |
| return "failure" | |
| } | |
| func doSomething() (string, error) { | |
| return "", nil | |
| } | |
| func main() { | |
| var result string | |
| var err error | |
| if result, err = doSomething(); err != nil { | |
| fmt.Println("We have received an error!") // Is never called. | |
| } else { | |
| fmt.Println(result) // Prints "". | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment