直接上代码:
package main
import "fmt"
type diaosi struct {
}
func (b *diaosi) LUALU() {
}
type decorator struct {
*diaosi
LUALU func()
}
func decorat(b *diaosi) (d *decorator) {
d = &decorator{b, nil}
d.LUALU = func() {
fmt.Println("take off trousers...")
b.LUALU()
fmt.Println("take on trousers...")
}
return
}
func main() {
b := &diaosi{}
b.LUALU()
fmt.Println("===========")
c := decorat(b)
c.LUALU()
}