~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/pkg/encoding/gob/doc.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 14:06:23 UTC
  • mfrom: (14.1.23 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130820140623-b414jfxi3m0qkmrq
Tags: 2:1.1.2-2ubuntu1
* Merge from Debian unstable (LP: #1211749, #1202027). Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
the destination variable must be able to represent the value or the decode
68
68
operation will fail.
69
69
 
70
 
Structs, arrays and slices are also supported.  Strings and arrays of bytes are
71
 
supported with a special, efficient representation (see below).  When a slice is
72
 
decoded, if the existing slice has capacity the slice will be extended in place;
73
 
if not, a new array is allocated.  Regardless, the length of the resulting slice
74
 
reports the number of elements decoded.
 
70
Structs, arrays and slices are also supported.  Structs encode and
 
71
decode only exported fields. Strings and arrays of bytes are supported
 
72
with a special, efficient representation (see below).  When a slice
 
73
is decoded, if the existing slice has capacity the slice will be
 
74
extended in place; if not, a new array is allocated.  Regardless,
 
75
the length of the resulting slice reports the number of elements
 
76
decoded.
75
77
 
76
78
Functions and channels cannot be sent in a gob.  Attempting
77
79
to encode a value that contains one will fail.
118
120
 
119
121
Maps are sent as an unsigned count followed by that many key, element
120
122
pairs. Empty but non-nil maps are sent, so if the sender has allocated
121
 
a map, the receiver will allocate a map even no elements are
 
123
a map, the receiver will allocate a map even if no elements are
122
124
transmitted.
123
125
 
124
126
Structs are sent as a sequence of (field number, field value) pairs.  The field
328
330
        01      // Add 1 to get field number 0: field[1].name
329
331
        01      // 1 byte
330
332
        59      // structType.field[1].name = "Y"
331
 
        01      // Add 1 to get field number 1: field[0].id
 
333
        01      // Add 1 to get field number 1: field[1].id
332
334
        04      // struct.Type.field[1].typeId is 2 (signed int).
333
335
        00      // End of structType.field[1]; end of structType.field.
334
336
        00      // end of wireType.structType structure