Skip to content

Instantly share code, notes, and snippets.

@mkock
Last active October 3, 2021 09:25
Show Gist options
  • Select an option

  • Save mkock/704878167933eccd155a4054766b5987 to your computer and use it in GitHub Desktop.

Select an option

Save mkock/704878167933eccd155a4054766b5987 to your computer and use it in GitHub Desktop.
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