It's only items that will be received as interface values that need to
be registered. The recipient decoder knows only what the stream says,
which is the interface pair (type, value), and unlike with other
decoders or concrete (non-interface types) with gob encoding, there is
no value extant of the appropriate concrete type to decode into.
Registration is needed on the receiver (decoder), only, so it can have
an example of the concrete type to duplicate when it wants to store
the received value.

In short, other decoders are passed a concrete type to decode into,
*int say or *Foo, but gob's interface values are decoded by the
receiver with no information except what the stream says. It needs a
little help.

Try using encoding/binary to encode an int32 and decode it into a
value of type interface{} and you'll see the problem. (Hint: you
can't, not directly.)


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/groups/opt_out.

Search Discussions

Discussion Posts


Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 3 | next ›
Discussion Overview
groupgolang-nuts @
postedAug 12, '13 at 12:38p
activeAug 12, '13 at 1:14p



site design / logo © 2022 Grokbase