August 2019
Beginner to intermediate
798 pages
17h 2m
English
Go functions can accept other Go functions as parameters, which is a feature that adds versatility to what you can do with a Go function. The two most common uses of this functionality are functions for sorting elements and the filepath.Walk() function. However, in the example presented here, which is named funFun.go, we will implement a much simpler case that deals with integer values. The relevant code will be presented in three parts.
The first code segment of funFun.go is shown in the following Go code:
package main
import "fmt"
func function1(i int) int {
return i + i
}
func function2(i int) int {
return i * i
}
What we have here is two functions that both accept an int and return ...
Read now
Unlock full access