https://github.com/kimtore/closures-in-go
Demo code for Go Oslo user meetup 2019-10-09
https://github.com/kimtore/closures-in-go
Last synced: about 1 month ago
JSON representation
Demo code for Go Oslo user meetup 2019-10-09
- Host: GitHub
- URL: https://github.com/kimtore/closures-in-go
- Owner: kimtore
- License: mit
- Created: 2019-10-07T12:11:00.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-10-09T14:14:51.000Z (over 5 years ago)
- Last Synced: 2025-02-08T07:09:57.387Z (3 months ago)
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Closures in Go
## What are closures?
- Wikipedia mentions: "a closure is a technique for implementing lexically scoped name binding in a language with first-class functions."
## What does that mean?
- We may write functions with access to the current scope, put the function in a variable, and pass it to a different part of the application that normally doesn't have access.
## Why bother?
- Create methods that have asynchronous operation.
- Send local objects to remote places. Examples are e.g. database handles or logging instances.## Repository examples are in pkg/
## Real world examples
- [Naiserator](https://github.com/nais/naiserator) is a Kubernetes operator written by NAV.
It manages Kubernetes resources using a _create, update or delete_ mechanism implemented with closures.