Potential issue with the gob package

Please observe the Go Playground example:
Go playground example

In essence, the gob Encoder will write the type definition of the encoded value to the bytes stream on the first encoding, but any subsequent encoding will omit the type definition.

This is inconsistent.

I understand that I am supposed to use the Decoder on the other end, but what if I have multiple endpoints that do round-robin receiving of the encoded streams? The first in order will get the type definition, and the second in order will not.

Is it supposed to be a one-to-one only transmission?

Also note that I Register the type on init().

My issue was that I was verifying the hash of the populated struct and I would not get the same hashes due to the inconsistent write to the buffer.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.