Closure
Closure occurs when an anonymous function in Go has access to its surroundings. Then it can hold a unique state of its own. The state then becomes isolated as we create new instances of the function.
Data isolation of a closure
Data isolation is a property that is available in the closure function. The state of the closures become unique when created. This makes each one of them having its own state. Here is an example.
Uses of a Closure
The closure property is used extensively where data isolation is required. The state provided by the closures makes them immensely helpful in that regard. When we want to create a state encapsulated function we use closures to do that.