diff options
author | Rob Pike <r@golang.org> | 2010-12-14 14:04:52 -0800 |
---|---|---|
committer | Rob Pike <r@golang.org> | 2010-12-14 14:04:52 -0800 |
commit | 9f6de01d8d0f7c17fd88ed1d3082ee856acb2beb (patch) | |
tree | 51b21764e88789b9a94bc5e0e4bf3fbc06d211e4 | |
parent | 8b64cd9c5e13768828d1f5f979c62680b5e90ff0 (diff) | |
download | go-9f6de01d8d0f7c17fd88ed1d3082ee856acb2beb.tar.gz go-9f6de01d8d0f7c17fd88ed1d3082ee856acb2beb.zip |
gob: document the byte count used in the encoding of values.
R=rsc
CC=golang-dev
https://golang.org/cl/3641041
-rw-r--r-- | src/pkg/gob/doc.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/pkg/gob/doc.go b/src/pkg/gob/doc.go index 2e7232db51..5d9eb51800 100644 --- a/src/pkg/gob/doc.go +++ b/src/pkg/gob/doc.go @@ -70,7 +70,7 @@ operation will fail. Structs, arrays and slices are also supported. Strings and arrays of bytes are supported with a special, efficient representation (see below). -Interfaces, functions, and channels cannot be sent in a gob. Attempting +Functions and channels cannot be sent in a gob. Attempting to encode a value that contains one will fail. The rest of this comment documents the encoding, details that are not important @@ -202,9 +202,14 @@ priori, as well as the basic gob types int, uint, etc. Their ids are: // 22 is slice of fieldType. mapType 23 +Finally, each message created by a call to Encode is preceded by an encoded +unsigned integer count of the number of bytes remaining in the message. After +the initial type name, interface values are wrapped the same way; in effect, the +interface value acts like a recursive invocation of Encode. + In summary, a gob stream looks like - ((-type id, encoding of a wireType)* (type id, encoding of a value))* + (byteCount (-type id, encoding of a wireType)* (type id, encoding of a value))* where * signifies zero or more repetitions and the type id of a value must be predefined or be defined before the value in the stream. |