]> Cypherpunks repositories - gostls13.git/commit
gob: allow exchange of interface values
authorRob Pike <r@golang.org>
Fri, 22 Oct 2010 18:17:40 +0000 (11:17 -0700)
committerRob Pike <r@golang.org>
Fri, 22 Oct 2010 18:17:40 +0000 (11:17 -0700)
commit5d9064697b81fa6e6c23d5566e1d5e456f295777
tree53a840bc940542923ff96ddb811c77871e4ff88b
parent3478891d1202c1324b096a61da2294dade732c63
gob: allow exchange of interface values

The implemetation describes each value as a string identifying the
concrete type of the value, followed by the usual encoding of that
value.  All types to be exchanged as contents of interface values
must be registered ahead of time with the new Register function.
Although this would not seem strictly necessary, the linker garbage
collects unused types so without some mechanism to guarantee
the type exists in the binary, there could be unpleasant surprises.
Moreover, the receiver needs a reflect.Type of the value to be
written in order to be able to save the data. A Register function
seems necessary.

The implementation may require defining types in the middle of
of sending a value.  The old code never did this. Therefore there
has been some refactoring to make the encoder and decoder
work recursively.

This change changes the internal type IDs. Existing gob archives
will break with this change.  Apologies for that. If this is a deal
breaker it should be possible to create a conversion tool.

Error handling is too complicated in this code. A subsequent
change should clean it up.

R=rsc
CC=golang-dev
https://golang.org/cl/2618042
src/pkg/gob/codec_test.go
src/pkg/gob/decode.go
src/pkg/gob/decoder.go
src/pkg/gob/doc.go
src/pkg/gob/encode.go
src/pkg/gob/encoder.go
src/pkg/gob/encoder_test.go
src/pkg/gob/type.go