golang设计模式(三)装饰器模式

func decorator(f func(s1 string))func(s2 string)  {
	return func(s3 string) {
		fmt.Println("start")
		f(s3)
		fmt.Println("end")
	}
}

func hello(s string){
	fmt.Println(s)
}

func main(){
	decorator(hello)("hello")
}
posted @ 2022-02-24 20:08  故意写bug  阅读(114)  评论(0)    收藏  举报