Below you will find pages that utilize the taxonomy term “Closure”
Article
Closure in go
closure is a function inside another function where you can reference variable defined in the outer function.
I have seen them useful in dealing with packages where a function expects an type func() as an argument where the func() doesn’t take any argument.
example from package github.com/cenkalti/backoff
signature of backoff.Retry is as below
backoff.Retry(o backoff.Operation, b backoff.Backoff) where backoff.Operation is of type func() error
type Operation func() error func main() { func retryWrapper(imp string) func() error{ return func() { funcThatCouldFail(imp) retun nil } } err := backoff.