Skip to content

Instantly share code, notes, and snippets.

@PeteGabriel
Created July 29, 2022 08: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 PeteGabriel/75bb4b28488b254ee0acabe4bb7278e0 to your computer and use it in GitHub Desktop.
Save PeteGabriel/75bb4b28488b254ee0acabe4bb7278e0 to your computer and use it in GitHub Desktop.
package main
import (
"errors"
"fmt"
)
func main() {
var err error
defer func() {
if err != nil {
fmt.Printf("error found: %v", err)
}
}()
err = throwError()
// imagine having more cases where an error can be thrown.
}
func throwError() error {
return errors.New("New Error")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment