Last active
October 3, 2021 09:26
-
-
Save mkock/75cd677c669865875fa3ff8f4a9831a3 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, *myError) { | |
| return "", nil | |
| } | |
| func main() { | |
| var result string | |
| var err error | |
| if result, err = doSomething(); err != nil { | |
| fmt.Println("We have received an error!") // Prints "We have received an error!" | |
| } else { | |
| fmt.Println(result) // Is never called. | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment