forked from go/golangs_learn
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
412 B
33 lines
412 B
3 years ago
|
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()
|
||
|
}
|