Skip to content

Latest commit

 

History

History
18 lines (16 loc) · 497 Bytes

README.md

File metadata and controls

18 lines (16 loc) · 497 Bytes

代码结构

- src
  - Context.go # 抽象业务类,聚合策略对象
  - ContextCat.go # 具体的业务实现,可绑定某个策略
  - ContextDog.go # 具体的业务实现,可绑定某个策略
  - Strategy.go # 策略抽象接口,定义策略基本行为
  - StrategyA.go # 具体的策略实现者
  - StrategyB.go # 具体的策略实现者
  - StrategyC.go # 具体的策略实现者

测试验证

$ cd ./strategy-pattern/go
$ go run test/test.go