Returning Errors
This lesson talks about Displaying error messages in Go and use of fmt package for printing
We'll cover the following
Returning an Error Message
In the previous lessons, we learned how to implement interfaces in Go. We will now look at how we can display error messages within them. An error is anything that can describe itself as an error string. The idea is captured by the predefined, built-in interface type, error, with its single method, Error
, returning a string:
Get hands-on with 1400+ tech skills courses.