![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
设计模式
落魄陶陶
这个作者很懒,什么都没留下…
展开
-
设计模式Go版-单例模式
----------------------------------singleton.go-------------------------------------------------package singletonimport ( "sync" "fmt")var ( once sync.Once instance *Singleton原创 2018-01-31 11:24:07 · 304 阅读 · 0 评论 -
设计模式Go版-简单工厂
----------------simple.go-----------------package factory// 定义通用接口type Operation interface { GetResult() float64 SetNumA(float64) SetNumB(float64)}// 定义通用实现类及方法type BaseOperation str原创 2018-01-24 17:44:54 · 256 阅读 · 0 评论 -
设计模式Go版-策略模式
----------------strategy.go-----------------package strategyconst STRATEGY_300_RETURN_299 = "满300返299"const STRATEGY_REBATE_80 = "八折"type CashAcceptor interface { AcceptCash(float64) f原创 2018-01-26 16:31:12 · 502 阅读 · 0 评论 -
设计模式Go版-装饰器模式
----------------------------------decorator.go-------------------------------------------------package decoratorimport "fmt"//定义公用接口type Shower interface { Show()}//实现了公用接口的具体的类type Per原创 2018-01-29 10:49:21 · 1507 阅读 · 0 评论