Hi,
I'm trying to use Gob to save some data structures. It seems to be really clean, which is very nice. However, I'm getting an error involving interfaces, and I'm not sure how to fix the issue. The relevant piece of code is
http://play.golang.org/p/daRidNhjuL (Though the actual code is more complicated)
Running it like this, I get the error,
gob: local interface type *nnet.reshaper can only be decoded from remote interface type; received concrete type sigmoidneuron = struct { }
The gob package doc says "Interface values are transmitted as a string identifying the concrete type being sent (a name that must be pre-defined by calling Register), followed by a byte count of the length of the following data (so the value can be skipped if it cannot be stored), followed by the usual encoding of concrete (dynamic) value stored in the interface value."
Is there a way to dynamically register the underlying types of the interface value as I encode them? I tried
gob.Register(neur.reshaper)
gob.Register(& neur.reshaper)
gob.Register(reflect.ValueOf(neur.reshaper))
and
gob.Register(reflect.TypeOf(neur.reshaper))
None of which work. It even did not work when I added
gob.Register(&sigmoidneuron{})
gob.Register(&linearneuron{})
To all of the places where gob is active as in
http://play.golang.org/p/3WHq789HtH
I'm confused. Thanks