Go expresses error state with error
values. There’s no try-except
or try-catch
blocks.
Functions often return error
value (by convention should be always last), and it’s a responsibility of the calling code to handle errors.
Example:
error
package is used to handle errors in Go.
Built-in error
type is used for errors.
The error built-in interface type is the conventional interface for representing an error condition, with the nil value representing no error.