Go does not have an exception mechanism like try/catch in Java, we cannot throw an exception in Go.
Go uses a different mechanism which is known as defer-panic-and-recover mechanism.
Go handles simple errors for function, methods by returning an error object. The error object may be the only or the last return value. The error object is nil if there is no error in the function.
We should always check the error at the calling statement, if we receive any of it or not.
We should never ignore errors, it may lead to program crashes.
The way go detect and report the error condition is
Go has predefined error interface type
We can define error type by using error.New from the error package and provide an appropriate error message like:
Go Error Example
Math: negative number passed to Sqrt 8