package visitor import "fmt" type IVisitor interface { Visit() } type WeiBoVisitor struct { } func (w *WeiBoVisitor) Visit() { fmt.Println("调用::WeiBoVisitor") } type WeiXinVisitor struct { } func (w *WeiXinVisitor) Visit() { fmt.Println("调用::WeiXinVisitor") } type IElement interface { Accept(v IVisitor) } type Element struct { } func (e *Element) Accept(v IVisitor) { v.Visit() }