chain of responsibility1 golang design pattern #11 Chain of Responsibility Chain of Responsibility 패턴은 어떠한 요청을 다음 대상에게 넘겨주는 패턴으로 여러 이벤트를 체인을 거치면서 처리하게 됩니다. 예제 코드를 알아보기 전에 golang의 embedding에 관한 특성 중 하나를 알아야 할게 있습니다. 1 2 3 4 5 6 7 8 9 10 11 12 13 type Monster interface { Attack() } type Goblin struct {} func (g *Goblin) Attack() { fmt.Println("goblin attacks!") } type GoblinKing struct { Goblin } cs 위 코드에서 GoblinKing 구조체에서 Goblin을 embedding 하였습니다. 이렇게 하면 GoblinKing 객체에서 .. 2021. 11. 16. 이전 1 다음