1
0
mirror of https://github.com/tmrts/go-patterns.git synced 2024-11-22 04:56:09 +03:00
go-patterns/decorator.go

25 lines
346 B
Go
Raw Normal View History

2015-12-23 16:46:27 +03:00
package main
import (
"fmt"
"log"
)
func LogDecorate(fn func(s string)) func(s string) {
return func(s string) {
log.Println("Starting the execution with the argument", s)
fn(s)
log.Println("Execution is completed.")
}
}
func Function(s string) {
fmt.Println(s)
}
func main() {
f := LogDecorate(Function)
f("Hello Decorator")
}