【发布时间】:2014-05-19 00:39:08
【问题描述】:
例如,我有这个结构:
type MapReduce struct {
nMap int // Number of Map jobs
nReduce int // Number of Reduce jobs
file string // Name of input file
MasterAddress string
registerChannel chan string
DoneChannel chan bool
alive bool
l net.Listener
stats *list.List
// Map of registered workers that you need to keep up to date
Workers map[string]*WorkerInfo
// add any additional state here
}
然后我像这样新建它:
mr := new(MapReduce)
然后我这样使用它:
rpcs := rpc.NewServer()
rpcs.Register(mr)
我的问题是,rpc.Register 将接口作为参数。 http://golang.org/pkg/net/rpc/#Server
但是mr这里不是接口,为什么是对的?
谢谢
【问题讨论】:
标签: go