Hi Axel,

On Thursday, 15 August 2019 09:13:17 UTC+1, Axel Wagner wrote:
>
> I haven't really used gob much, so unfortunately I can't *really* help 
> you. But one thing to note is that you can dump the content of the buffer 
> and see that it doesn't actually contain the name of the type you are 
> encoding: https://play.golang.org/p/R8HB6RP8kS0
>

You are right.  But the type is somehow represented by some index or so, 
instead of the name?  Since the type needs to be registered using 
gob.Register() beforehand, this seems not totally impossible to me.  But 
then, when I change your code to let gob do the encoding itself, the name 
is suddenly there: https://play.golang.org/p/Qz7zDKL047z, so probably the 
absence of the type name is part of the problem.
 

> And I agree that this probably shouldn't panic, but instead return an 
> error. But given that the encoded bytes don't contain the name of the 
> concrete struct, there is no way the decoder can know where you want to put 
> it, without giving it the correct type.
>

Yes, an informative error instead of the hard to interpret panic would be 
nice.  I wonder whether this is indeed intended behaviour, or whether this 
is some kind of bug in the encoding/gob package.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/32c27653-c50b-42cd-a525-8c9e9298bf60%40googlegroups.com.

Reply via email to