anonymous function

A function written inline without a name, often started as a goroutine or passed to another function.

In more detail

Anonymous functions are often passed to other functions or started as background work. One that uses variables from the code around it is called a closure.

Examples

go func(target string) {
	defer wait.Done()
	fmt.Println(target)
}(name)
Go: go func(target string) { ... }(name) starts one as a goroutine

Related terms

Taught in

References