Skip to content

Instantly share code, notes, and snippets.

@pein0119
Forked from alehano/Golang decorator
Created October 25, 2016 06:09
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 pein0119/a43e085168945dd9c0451514d9294c12 to your computer and use it in GitHub Desktop.
Save pein0119/a43e085168945dd9c0451514d9294c12 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
)
func decorator(f func(s string)) func(s string) {
return func(s string) {
fmt.Println("Started")
f(s)
fmt.Println("Done")
}
}
func doSomething(s string) {
fmt.Println(s)
}
func main() {
decorator(doSomething)("Do something")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment