Naming Return Values in Go Functions

Let's learn about functions that have named return values.

We'll cover the following

Unlike C, Go allows us to name the return values of a Go function. Additionally, when such a function has a return statement without any arguments, the function automatically returns the current value of each named return value in the order in which they were declared in the function signature.

Coding example

The following function is included in namedReturn.go:

Get hands-on with 1200+ tech skills courses.