golang回调函数的例子

package main

import "fmt"

type TestStruct struct {
}

func (object *TestStruct) test(msg string) {
    fmt.Println(msg)
}

type CallBack func(msg string)

func callBackTest(pFunc CallBack) {
    pFunc("111111")
}

func main() {
    object := new(TestStruct)
    callBackTest(object.test)
}

 

posted @ 2014-08-02 21:50  自由出土文物  阅读(1237)  评论(0编辑  收藏  举报