1
0
mirror of https://github.com/tmrts/go-patterns.git synced 2024-11-25 06:26:06 +03:00

Add decorator pattern

This commit is contained in:
Tamer Tas 2015-12-23 15:46:27 +02:00
parent aeca31fe3d
commit 7680a25f35

24
decorator.go Normal file
View File

@ -0,0 +1,24 @@
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")
}