github.com/dennys-bd/goals@v0.0.0-20210328114421-251a004d41e3/shortcuts/errors/errors.go (about) 1 package errors 2 3 import ( 4 "fmt" 5 "os" 6 ) 7 8 // CheckEx function verify if error is nil and calls Ex() on error 9 func CheckEx(err error) { 10 if err != nil { 11 Ex(err.Error()) 12 } 13 } 14 15 // Ex function print error and exits 16 func Ex(msg interface{}) { 17 fmt.Println("Error:", msg) 18 os.Exit(1) 19 } 20 21 // Check function verify if error is nil and panics on error 22 func Check(err error) { 23 if err != nil { 24 panic(err.Error()) 25 } 26 }