Hi all,
I am running into a problem with gob with some code. A simplified
example is here:
https://play.golang.org/p/hx8A5iqF-p
From the gob documentation:
"Pointers are not transmitted, but the things they point to are
transmitted; that is, the values are flattened. [...] 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, it is clear why decoding does not work: while encoding the only
slice member, the value is flattened. In the gob, Foo is stored and
not *Foo. During decoding, the assignability check fails, because
Frob() is implemented on Foo and not Foo. The decoding problem is
easily fixed by implementing Frob() on Foo.
But what if I actually only want to implement Frob() with a pointer
receiver? Wouldn't it make sense if gob tried if taking the address of
the value would fulfil the interface when the value doesn't fulfil the
interface? Or am I missing something?
Kind regards,
Daniël de Kok