Skip to content

Instantly share code, notes, and snippets.

@matejb
Created August 21, 2018 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matejb/80245a986b9aec0eafcb4c8eab24d2d9 to your computer and use it in GitHub Desktop.
Save matejb/80245a986b9aec0eafcb4c8eab24d2d9 to your computer and use it in GitHub Desktop.
chain golang
package main
import (
"fmt"
)
func main() {
chain(a).chain(b).chain(c)()
}
type chain func()
func (c chain) chain(f func()) chain {
return func() {
c()
f()
}
}
func a() {
fmt.Println("a")
}
func b() {
fmt.Println("b")
}
func c() {
fmt.Println("c")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment