1

I was wondering whether it is possible in go to initiate an RPC with a reply pointer to a value that looks like

type NSReply struct {
    Done int
    Reply interface {}
}

In my case, I'm getting the error:

rpc: gob error encoding body: gob: type not registered for interface: paxos.PrepareReply

where NSReply.Reply's type is paxos.PrepareReply. I'm very new to go, so I'm not so familiar with how golang's gobs work and I'm not sure what I'm trying to do is even allowed, but I can't find anything on whether it is. The intent was allow me to pass many different types of structs as payloads in NSReply.Reply.

wfehrnstrom
  • 329
  • 2
  • 17
  • 1
    The docs seem pretty clear on this... https://golang.org/pkg/encoding/gob/#example__interface – chash May 06 '20 at 20:08
  • 2
    rpc's gob is golang's gob. The registry is global. Have you tried registering the types that will be used as interfaces using `gob.Register()`? – chash May 06 '20 at 20:21
  • I did, and it worked as expected. Thank you very much, I didn't realize gob was a singleton – wfehrnstrom May 06 '20 at 22:01

0 Answers0