August 2019
Beginner to intermediate
798 pages
17h 2m
English
As you already know from functions such as strconv.Atoi(), Go functions can return multiple distinct values, which saves you from having to create a dedicated structure for returning and receiving multiple values from a function. You can declare a function that returns four values (two int values, one float64 value, and one string) as follows:
func aFunction() (int, int, float64, string) {
}
It is now time to illustrate anonymous functions and functions that return multiple values in more detail using the Go code of functions.go as an example. The relevant code will be presented in five parts.
The first code portion of functions.go is as follows:
package main
import (
"fmt"
"os"
"strconv"
)
The second ...
Read now
Unlock full access