Quidest?

Multiple values in Go functions

ยท Lorenzo Drumond

Go functions are not limited to returning just a single value.

It is very common for Go functions to return two values: the first being the result of the computation (the data value), and the second being an error value.

The error value indicates whether or not the data value is valid.

When the function receives valid input and return successfully, its error value should be set to nil. Otherwise, it should be something meaningful. The convention for the non error value is to return 0.

References

#values #golang #errors #programming #functions