Hi all,

I am running into a problem with gob with some code. A simplified
example is here:


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

You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 2 | next ›
Discussion Overview
groupgolang-nuts @
postedAug 28, '15 at 9:14a
activeAug 31, '15 at 9:42a

1 user in discussion

Daniël de Kok: 2 posts



site design / logo © 2021 Grokbase