I am trying to send a concrete implementation over RPC. The RPC methods expects a interface.
The relevant code snippets are:
In package node
:
type Commander interface {
Action() string
}
type Approach struct {
Position int
}
func (p Approach) Action() string {
return "Approach"
}
func (t *RPCMethod) RPCAction(command Commander, reply *int) error {
// RPC Method
}
In package main
:
import "node"
gob.Register(node.Approach{})
var p = node.Approach{position}
var q node.Commander = p
var reply int
err = client.Call("RPCMethod.RPCAction",&q, &reply)
I have registered the node.Approach with the gob. But on running the main program I am receiving
gob: name not registered for interface: "node.Approach"
Any ideas on what I am doing wrong? Or how to register name?