Hi Axel,

Thanks a lot for looking into this.  Your post makes things much clearer 
for me.  In particular, I now think that I probably should not have 
(Un)MarshalBinary() methods on the interface type, but have them only on 
the concrete type instead.  For example, this 
works: https://play.golang.org/p/oBgHqN74ZeM .

On Thursday, 15 August 2019 11:16:45 UTC+1, Axel Wagner wrote:
>
> The panic, I think, comes from the fact that you pass a *Duck, which then 
> gets dereferenced, pointing at a nil Duck. Even a nil-Duck *does* have a 
> DecodeBinary method though, so gob thinks it should use that. It then 
> type-asserts to BinaryDecoder, which panics, because it's a nil-interface, 
> just like this example: https://play.golang.org/p/EEwOt0FQunh.
>

I had forgotten that type assertions don't allow nil values, but indeed 
they don't.  Thank you for reminding me.

Many thanks,
Jochen

-- 
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/a707a33a-ea3a-4103-84f8-24d56a91fdae%40googlegroups.com.

Reply via email to