// Simple function with closure in Go // @author gtowell // August 2021 package main import "fmt" // define type for returnbed function -- it is just easier type Clo1 func(int) func main() { ff := makefun(100) gg(ff, 7) } // function that receives the function (with its closure) func gg(fff Clo1, jj int) { fff(jj) } func makefun(ii int) Clo1 { a := func(bb int) { fmt.Printf("FUNC: %d\n", (ii + bb)) } return a }