go装饰模式,一个屌丝撸管的故事

直接上代码:

创新互联专注于个旧网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供个旧营销型网站建设,个旧网站制作、个旧网页设计、个旧网站官网定制、微信平台小程序开发服务,打造个旧网络公司原创品牌,更为您提供个旧网站排名全网营销落地服务。

package main

import "fmt"

//现在有个屌丝,有个撸管方法,我们的需求是在撸管前后***子穿裤子
type diaosi struct {
}

func (b *diaosi) LUALU() {
    fmt.Println("EN... A.. A...OH GOD..FUCK ..ME..")
}

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()
    //作业:屌丝打开×××->***子->撸啊撸->穿裤子->关××× 怎么实现?
}

网站标题:go装饰模式,一个屌丝撸管的故事
网站网址:http://csdahua.cn/article/giphis.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流