You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Encode values using gob while reusing the encoder in a loop: https://go.dev/play/p/T3aHmYmKjid. As soon as the encoder is created inside the loop the problem is solved.
What did you expect to see?
No error.
What did you see instead?
Error during decoding:
panic: gob: decoding into local type []float64, received remote type []float
The text was updated successfully, but these errors were encountered:
The encoder delivers a stream that includes type information. If you
reuse the stream to a different decoder, that decoder will not have
seen the type information sent to the first one.
Or to look at it another way, the encoder just sends the values you
give it, along with any type information that has not already been
transmitted. In effect, it can't tell the difference between calling
it twice to deliver to one encoder and calling it twice to deliver to
two decoders.
Don't reuse the encoder.
-rob
That said: is that clear enough from the gob docs? It contained information about how types are encoded, but I couldn't find anything related to usage.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Reproduces with gotip
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Encode values using gob while reusing the encoder in a loop: https://go.dev/play/p/T3aHmYmKjid. As soon as the encoder is created inside the loop the problem is solved.
What did you expect to see?
No error.
What did you see instead?
Error during decoding:
The text was updated successfully, but these errors were encountered: