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
Learn How To Code: Google’s Go (golang) Programming Language
do() is called, which returns an error. To use Go errors, you must include the package errors:
$ go run example.go -1 Something wrong
You can combine both the return values:
r, e := do()