Go has a builtin type for errors. In Go, an error is the last return value (They have type error).
errors.New creates a new error with a message. If there is no error, you can return the
do() is called, which returns an error. To use Go errors, you must include the package errors:
$ go run example.go
You can combine both the return values:
r, e := do()
Leave a Reply