go error handling code example
Example 1: golang create error
// simple string-based error
err1 := errors.New("math: square root of negative number")
Example 2: go error handling
func doStuff() (int, error) {
}
func main() {
result, err := doStuff()
if err != nil {
// handle error
} else {
// all is good, use result
}
}