March 2020
Intermediate to advanced
406 pages
8h 39m
English
The first step to understanding closures in Go is to understand anonymous functions. An anonymous function is created using a variable for the inception of the function. They are also functions that don't have a name or identifier, hence the name anonymous functions.
A normal function invocation to print Hello Go to the screen would be what is shown in the following code block:
func HelloGo(){ fmt.Println("Hello Go")}
Next, we could call HelloGo() and the function would print a Hello Go string.
If we wanted to instantiate our HelloGo() function as an anonymous function, we would invoke this as referenced in the following code block:
// Note the trailing () for this anonymous function invocationfunc() { fmt.Println("Hello ...Read now
Unlock full access