import "fmt"
type Component interface {
Operate()
}
type Component1 struct {
}
func(this *Component1)Operate(){
fmt.Println("c1 operate...")
}
type Decorate interface {
Component
Do()
}
type Decorate1 struct{
//Component1
C Component
}
func (this *Decorate1) Do(){
fmt.Println("发生了---装饰者模式")
}
func (this *Decorate1)Operate(){
this.Do()
this.C.Operate()
}
测试代码:
func TestDecorate(t *testing.T){
decorate1:=inital.Decorate1{}
decorate1.C=&inital.Component1{}
decorate1.Do()
decorate1.Operate()
}


