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