Functions
Bytes
method
#
func (d *decBuffer) Bytes() []byte
Bytes
method
#
func (e *encBuffer) Bytes() []byte
Debug
function
#
Debug prints a human-readable representation of the gob data read from r.
It is a no-op unless debugging was enabled when the package was built.
func Debug(r io.Reader)
Decode
method
#
Decode reads the next value from the input stream and stores
it in the data represented by the empty interface value.
If e is nil, the value will be discarded. Otherwise,
the value underlying e must be a pointer to the
correct type for the next data item received.
If the input is at EOF, Decode returns [io.EOF] and
does not modify e.
func (dec *Decoder) Decode(e any) error
DecodeValue
method
#
DecodeValue reads the next value from the input stream.
If v is the zero reflect.Value (v.Kind() == Invalid), DecodeValue discards the value.
Otherwise, it stores the value into v. In that case, v must represent
a non-nil pointer to data or be an assignable reflect.Value (v.CanSet())
If the input is at EOF, DecodeValue returns [io.EOF] and
does not modify v.
func (dec *Decoder) DecodeValue(v reflect.Value) error
Drop
method
#
func (d *decBuffer) Drop(n int)
Encode
method
#
Encode transmits the data item represented by the empty interface value,
guaranteeing that all necessary type information has been transmitted first.
Passing a nil pointer to Encoder will panic, as they cannot be transmitted by gob.
func (enc *Encoder) Encode(e any) error
EncodeValue
method
#
EncodeValue transmits the data item represented by the reflection value,
guaranteeing that all necessary type information has been transmitted first.
Passing a nil pointer to EncodeValue will panic, as they cannot be transmitted by gob.
func (enc *Encoder) EncodeValue(value reflect.Value) error
Len
method
#
func (e *encBuffer) Len() int
Len
method
#
func (d *decBuffer) Len() int
NewDecoder
function
#
NewDecoder returns a new decoder that reads from the [io.Reader].
If r does not also implement [io.ByteReader], it will be wrapped in a
[bufio.Reader].
func NewDecoder(r io.Reader) *Decoder
NewEncoder
function
#
NewEncoder returns a new encoder that will transmit on the [io.Writer].
func NewEncoder(w io.Writer) *Encoder
Read
method
#
Read is the usual method. It will first take data that has been read ahead.
func (p *peekReader) Read(b []byte) (n int, err error)
Read
method
#
func (d *decBuffer) Read(p []byte) (int, error)
ReadByte
method
#
func (d *decBuffer) ReadByte() (byte, error)
Register
function
#
Register records a type, identified by a value for that type, under its
internal type name. That name will identify the concrete type of a value
sent or received as an interface variable. Only types that will be
transferred as implementations of interface values need to be registered.
Expecting to be used only during initialization, it panics if the mapping
between types and names is not a bijection.
func Register(value any)
RegisterName
function
#
RegisterName is like [Register] but uses the provided name rather than the
type's default.
func RegisterName(name string, value any)
Reset
method
#
func (e *encBuffer) Reset()
Reset
method
#
func (d *decBuffer) Reset()
SetBytes
method
#
SetBytes sets the buffer to the bytes, discarding any existing data.
func (d *decBuffer) SetBytes(data []byte)
String
method
#
func (t tab) String() string
Write
method
#
func (e *encBuffer) Write(p []byte) (int, error)
WriteString
method
#
func (e *encBuffer) WriteString(s string)
allocValue
function
#
Gob depends on being able to take the address
of zeroed Values it creates, so use this wrapper instead
of the standard reflect.Zero.
Each call allocates once.
func allocValue(t reflect.Type) reflect.Value
arrayValue
method
#
ArrayValue:
uint(n) FieldValue*n
func (deb *debugger) arrayValue(indent tab, wire *wireType)
bootstrapType
function
#
used for building the basic types; called only from init(). the incoming
interface always refers to a pointer.
func bootstrapType(name string, e any) typeId
buildEncEngine
function
#
func buildEncEngine(info *typeInfo, ut *userTypeInfo, building map[*typeInfo]bool) *encEngine
buildTypeInfo
function
#
buildTypeInfo constructs the type information for the type
and stores it in the type info map.
func buildTypeInfo(ut *userTypeInfo, rt reflect.Type) (*typeInfo, error)
builtinIdToType
function
#
func builtinIdToType(id typeId) gobType
catchError
function
#
catchError is meant to be used as a deferred function to turn a panic(gobError) into a
plain error. It overwrites the error return of the function that deferred its call.
func catchError(err *error)
checkId
function
#
func checkId(want typeId, got typeId)
common
method
#
common returns the CommonType at the input point.
func (deb *debugger) common() CommonType
compatibleType
method
#
compatibleType asks: Are these two gob Types compatible?
Answers the question for basic types, arrays, maps and slices, plus
GobEncoder/Decoder pairs.
Structs are considered ok; fields will be checked later.
func (dec *Decoder) compatibleType(fr reflect.Type, fw typeId, inProgress map[reflect.Type]typeId) bool
compileDec
method
#
compileDec compiles the decoder engine for a value. If the value is not a struct,
it calls out to compileSingle.
func (dec *Decoder) compileDec(remoteId typeId, ut *userTypeInfo) (engine *decEngine, err error)
compileEnc
function
#
compileEnc returns the engine to compile the type.
func compileEnc(ut *userTypeInfo, building map[*typeInfo]bool) *encEngine
compileIgnoreSingle
method
#
compileIgnoreSingle compiles the decoder engine for a non-struct top-level value that will be discarded.
func (dec *Decoder) compileIgnoreSingle(remoteId typeId) *decEngine
compileSingle
method
#
compileSingle compiles the decoder engine for a non-struct top-level value, including
GobDecoders.
func (dec *Decoder) compileSingle(remoteId typeId, ut *userTypeInfo) (engine *decEngine, err error)
consumed
method
#
note that we've consumed some bytes
func (deb *debugger) consumed(n int)
debug
function
#
debug implements Debug, but catches panics and returns
them as errors to be printed by Debug.
func debug(r io.Reader) (err error)
decAlloc
function
#
decAlloc takes a value and returns a settable value that can
be assigned to. If the value is a pointer, decAlloc guarantees it points to storage.
The callers to the individual decoders are expected to have used decAlloc.
The individual decoders don't need it.
func decAlloc(v reflect.Value) reflect.Value
decBool
function
#
decBool decodes a uint and stores it as a boolean in value.
func decBool(i *decInstr, state *decoderState, value reflect.Value)
decBoolArray
function
#
func decBoolArray(state *decoderState, v reflect.Value, length int, ovfl error) bool
decBoolSlice
function
#
func decBoolSlice(state *decoderState, v reflect.Value, length int, ovfl error) bool
decComplex128
function
#
decComplex128 decodes a pair of unsigned integers, treats them as a
pair of floating point numbers, and stores them as a complex128 in value.
The real part comes first.
func decComplex128(i *decInstr, state *decoderState, value reflect.Value)
decComplex128Array
function
#
func decComplex128Array(state *decoderState, v reflect.Value, length int, ovfl error) bool
decComplex128Slice
function
#
func decComplex128Slice(state *decoderState, v reflect.Value, length int, ovfl error) bool
decComplex64
function
#
decComplex64 decodes a pair of unsigned integers, treats them as a
pair of floating point numbers, and stores them as a complex64 in value.
The real part comes first.
func decComplex64(i *decInstr, state *decoderState, value reflect.Value)
decComplex64Array
function
#
func decComplex64Array(state *decoderState, v reflect.Value, length int, ovfl error) bool
decComplex64Slice
function
#
func decComplex64Slice(state *decoderState, v reflect.Value, length int, ovfl error) bool
decFloat32
function
#
decFloat32 decodes an unsigned integer, treats it as a 32-bit floating-point
number, and stores it in value.
func decFloat32(i *decInstr, state *decoderState, value reflect.Value)
decFloat32Array
function
#
func decFloat32Array(state *decoderState, v reflect.Value, length int, ovfl error) bool
decFloat32Slice
function
#
func decFloat32Slice(state *decoderState, v reflect.Value, length int, ovfl error) bool
decFloat64
function
#
decFloat64 decodes an unsigned integer, treats it as a 64-bit floating-point
number, and stores it in value.
func decFloat64(i *decInstr, state *decoderState, value reflect.Value)
decFloat64Array
function
#
func decFloat64Array(state *decoderState, v reflect.Value, length int, ovfl error) bool
decFloat64Slice
function
#
func decFloat64Slice(state *decoderState, v reflect.Value, length int, ovfl error) bool
decIgnoreOpFor
method
#
decIgnoreOpFor returns the decoding op for a field that has no destination.
func (dec *Decoder) decIgnoreOpFor(wireId typeId, inProgress map[typeId]*decOp) *decOp
decInt16
function
#
decInt16 decodes an integer and stores it as an int16 in value.
func decInt16(i *decInstr, state *decoderState, value reflect.Value)
decInt16Array
function
#
func decInt16Array(state *decoderState, v reflect.Value, length int, ovfl error) bool
decInt16Slice
function
#
func decInt16Slice(state *decoderState, v reflect.Value, length int, ovfl error) bool
decInt32
function
#
decInt32 decodes an integer and stores it as an int32 in value.
func decInt32(i *decInstr, state *decoderState, value reflect.Value)
decInt32Array
function
#
func decInt32Array(state *decoderState, v reflect.Value, length int, ovfl error) bool
decInt32Slice
function
#
func decInt32Slice(state *decoderState, v reflect.Value, length int, ovfl error) bool
decInt64
function
#
decInt64 decodes an integer and stores it as an int64 in value.
func decInt64(i *decInstr, state *decoderState, value reflect.Value)
decInt64Array
function
#
func decInt64Array(state *decoderState, v reflect.Value, length int, ovfl error) bool
decInt64Slice
function
#
func decInt64Slice(state *decoderState, v reflect.Value, length int, ovfl error) bool
decInt8
function
#
decInt8 decodes an integer and stores it as an int8 in value.
func decInt8(i *decInstr, state *decoderState, value reflect.Value)
decInt8Array
function
#
func decInt8Array(state *decoderState, v reflect.Value, length int, ovfl error) bool
decInt8Slice
function
#
func decInt8Slice(state *decoderState, v reflect.Value, length int, ovfl error) bool
decIntArray
function
#
func decIntArray(state *decoderState, v reflect.Value, length int, ovfl error) bool
decIntSlice
function
#
func decIntSlice(state *decoderState, v reflect.Value, length int, ovfl error) bool
decOpFor
method
#
decOpFor returns the decoding op for the base type under rt and
the indirection count to reach it.
func (dec *Decoder) decOpFor(wireId typeId, rt reflect.Type, name string, inProgress map[reflect.Type]*decOp) *decOp
decString
function
#
decString decodes byte array and stores in value a string header
describing the data.
Strings are encoded as an unsigned count followed by the raw bytes.
func decString(i *decInstr, state *decoderState, value reflect.Value)
decStringArray
function
#
func decStringArray(state *decoderState, v reflect.Value, length int, ovfl error) bool
decStringSlice
function
#
func decStringSlice(state *decoderState, v reflect.Value, length int, ovfl error) bool
decUint16
function
#
decUint16 decodes an unsigned integer and stores it as a uint16 in value.
func decUint16(i *decInstr, state *decoderState, value reflect.Value)
decUint16Array
function
#
func decUint16Array(state *decoderState, v reflect.Value, length int, ovfl error) bool
decUint16Slice
function
#
func decUint16Slice(state *decoderState, v reflect.Value, length int, ovfl error) bool
decUint32
function
#
decUint32 decodes an unsigned integer and stores it as a uint32 in value.
func decUint32(i *decInstr, state *decoderState, value reflect.Value)
decUint32Array
function
#
func decUint32Array(state *decoderState, v reflect.Value, length int, ovfl error) bool
decUint32Slice
function
#
func decUint32Slice(state *decoderState, v reflect.Value, length int, ovfl error) bool
decUint64
function
#
decUint64 decodes an unsigned integer and stores it as a uint64 in value.
func decUint64(i *decInstr, state *decoderState, value reflect.Value)
decUint64Array
function
#
func decUint64Array(state *decoderState, v reflect.Value, length int, ovfl error) bool
decUint64Slice
function
#
func decUint64Slice(state *decoderState, v reflect.Value, length int, ovfl error) bool
decUint8
function
#
decUint8 decodes an unsigned integer and stores it as a uint8 in value.
func decUint8(i *decInstr, state *decoderState, value reflect.Value)
decUint8Slice
function
#
decUint8Slice decodes a byte slice and stores in value a slice header
describing the data.
uint8 slices are encoded as an unsigned count followed by the raw bytes.
func decUint8Slice(i *decInstr, state *decoderState, value reflect.Value)
decUintArray
function
#
func decUintArray(state *decoderState, v reflect.Value, length int, ovfl error) bool
decUintSlice
function
#
func decUintSlice(state *decoderState, v reflect.Value, length int, ovfl error) bool
decUintptrArray
function
#
func decUintptrArray(state *decoderState, v reflect.Value, length int, ovfl error) bool
decUintptrSlice
function
#
func decUintptrSlice(state *decoderState, v reflect.Value, length int, ovfl error) bool
decodeArray
method
#
decodeArray decodes an array and stores it in value.
The length is an unsigned integer preceding the elements. Even though the length is redundant
(it's part of the type), it's a useful check and is included in the encoding.
func (dec *Decoder) decodeArray(state *decoderState, value reflect.Value, elemOp decOp, length int, ovfl error, helper decHelper)
decodeArrayHelper
method
#
decodeArrayHelper does the work for decoding arrays and slices.
func (dec *Decoder) decodeArrayHelper(state *decoderState, value reflect.Value, elemOp decOp, length int, ovfl error, helper decHelper)
decodeGobDecoder
method
#
decodeGobDecoder decodes something implementing the GobDecoder interface.
The data is encoded as a byte slice.
func (dec *Decoder) decodeGobDecoder(ut *userTypeInfo, state *decoderState, value reflect.Value)
decodeIgnoredValue
method
#
decodeIgnoredValue decodes the data stream representing a value of the specified type and discards it.
func (dec *Decoder) decodeIgnoredValue(wireId typeId)
decodeInt
method
#
decodeInt reads an encoded signed integer from state.r.
Does not check for overflow.
func (state *decoderState) decodeInt() int64
decodeInterface
method
#
decodeInterface decodes an interface value and stores it in value.
Interfaces are encoded as the name of a concrete type followed by a value.
If the name is empty, the value is nil and no value is sent.
func (dec *Decoder) decodeInterface(ityp reflect.Type, state *decoderState, value reflect.Value)
decodeIntoValue
function
#
decodeIntoValue is a helper for map decoding.
func decodeIntoValue(state *decoderState, op decOp, isPtr bool, value reflect.Value, instr *decInstr) reflect.Value
decodeMap
method
#
decodeMap decodes a map and stores it in value.
Maps are encoded as a length followed by key:value pairs.
Because the internals of maps are not visible to us, we must
use reflection rather than pointer magic.
func (dec *Decoder) decodeMap(mtyp reflect.Type, state *decoderState, value reflect.Value, keyOp decOp, elemOp decOp, ovfl error)
decodeSingle
method
#
decodeSingle decodes a top-level value that is not a struct and stores it in value.
Such values are preceded by a zero, making them have the memory layout of a
struct field (although with an illegal field number).
func (dec *Decoder) decodeSingle(engine *decEngine, value reflect.Value)
decodeSlice
method
#
decodeSlice decodes a slice and stores it in value.
Slices are encoded as an unsigned length followed by the elements.
func (dec *Decoder) decodeSlice(state *decoderState, value reflect.Value, elemOp decOp, ovfl error, helper decHelper)
decodeStruct
method
#
decodeStruct decodes a top-level struct and stores it in value.
Indir is for the value, not the type. At the time of the call it may
differ from ut.indir, which was computed when the engine was built.
This state cannot arise for decodeSingle, which is called directly
from the user's value, not from the innards of an engine.
func (dec *Decoder) decodeStruct(engine *decEngine, value reflect.Value)
decodeTypeSequence
method
#
decodeTypeSequence parses:
TypeSequence
(TypeDefinition DelimitedTypeDefinition*)?
and returns the type id of the next value. It returns -1 at
EOF. Upon return, the remainder of dec.buf is the value to be
decoded. If this is an interface value, it can be ignored by
resetting that buffer.
func (dec *Decoder) decodeTypeSequence(isInterface bool) typeId
decodeUint
method
#
decodeUint reads an encoded unsigned integer from state.r.
Does not check for overflow.
func (state *decoderState) decodeUint() (x uint64)
decodeUintReader
function
#
decodeUintReader reads an encoded unsigned integer from an io.Reader.
Used only by the Decoder to read the message length.
func decodeUintReader(r io.Reader, buf []byte) (x uint64, width int, err error)
decodeValue
method
#
decodeValue decodes the data stream representing a value and stores it in value.
func (dec *Decoder) decodeValue(wireId typeId, value reflect.Value)
delimitedMessage
method
#
DelimitedMessage:
uint(lengthOfMessage) Message
func (deb *debugger) delimitedMessage(indent tab) bool
delta
method
#
delta returns the field delta at the input point. The expect argument,
if non-negative, identifies what the value should be.
func (deb *debugger) delta(expect int) int
dump
method
#
dump prints the next nBytes of the input.
It arranges to print the output aligned from call to
call, to make it easy to see what has been consumed.
func (deb *debugger) dump(format string, args ...any)
encBool
function
#
encBool encodes the bool referenced by v as an unsigned 0 or 1.
func encBool(i *encInstr, state *encoderState, v reflect.Value)
encBoolArray
function
#
func encBoolArray(state *encoderState, v reflect.Value) bool
encBoolSlice
function
#
func encBoolSlice(state *encoderState, v reflect.Value) bool
encComplex
function
#
encComplex encodes the complex value (complex64 complex128) referenced by v.
Complex numbers are just a pair of floating-point numbers, real part first.
func encComplex(i *encInstr, state *encoderState, v reflect.Value)
encComplex128Array
function
#
func encComplex128Array(state *encoderState, v reflect.Value) bool
encComplex128Slice
function
#
func encComplex128Slice(state *encoderState, v reflect.Value) bool
encComplex64Array
function
#
func encComplex64Array(state *encoderState, v reflect.Value) bool
encComplex64Slice
function
#
func encComplex64Slice(state *encoderState, v reflect.Value) bool
encFloat
function
#
encFloat encodes the floating point value (float32 float64) referenced by v.
func encFloat(i *encInstr, state *encoderState, v reflect.Value)
encFloat32Array
function
#
func encFloat32Array(state *encoderState, v reflect.Value) bool
encFloat32Slice
function
#
func encFloat32Slice(state *encoderState, v reflect.Value) bool
encFloat64Array
function
#
func encFloat64Array(state *encoderState, v reflect.Value) bool
encFloat64Slice
function
#
func encFloat64Slice(state *encoderState, v reflect.Value) bool
encIndirect
function
#
encIndirect dereferences pv indir times and returns the result.
func encIndirect(pv reflect.Value, indir int) reflect.Value
encInt
function
#
encInt encodes the signed integer (int int8 int16 int32 int64) referenced by v.
func encInt(i *encInstr, state *encoderState, v reflect.Value)
encInt16Array
function
#
func encInt16Array(state *encoderState, v reflect.Value) bool
encInt16Slice
function
#
func encInt16Slice(state *encoderState, v reflect.Value) bool
encInt32Array
function
#
func encInt32Array(state *encoderState, v reflect.Value) bool
encInt32Slice
function
#
func encInt32Slice(state *encoderState, v reflect.Value) bool
encInt64Array
function
#
func encInt64Array(state *encoderState, v reflect.Value) bool
encInt64Slice
function
#
func encInt64Slice(state *encoderState, v reflect.Value) bool
encInt8Array
function
#
func encInt8Array(state *encoderState, v reflect.Value) bool
encInt8Slice
function
#
func encInt8Slice(state *encoderState, v reflect.Value) bool
encIntArray
function
#
func encIntArray(state *encoderState, v reflect.Value) bool
encIntSlice
function
#
func encIntSlice(state *encoderState, v reflect.Value) bool
encOpFor
function
#
encOpFor returns (a pointer to) the encoding op for the base type under rt and
the indirection count to reach it.
func encOpFor(rt reflect.Type, inProgress map[reflect.Type]*encOp, building map[*typeInfo]bool) (*encOp, int)
encString
function
#
encString encodes the string referenced by v.
Strings are encoded as an unsigned count followed by the raw bytes.
func encString(i *encInstr, state *encoderState, v reflect.Value)
encStringArray
function
#
func encStringArray(state *encoderState, v reflect.Value) bool
encStringSlice
function
#
func encStringSlice(state *encoderState, v reflect.Value) bool
encStructTerminator
function
#
encStructTerminator encodes the end of an encoded struct
as delta field number of 0.
func encStructTerminator(i *encInstr, state *encoderState, v reflect.Value)
encUint
function
#
encUint encodes the unsigned integer (uint uint8 uint16 uint32 uint64 uintptr) referenced by v.
func encUint(i *encInstr, state *encoderState, v reflect.Value)
encUint16Array
function
#
func encUint16Array(state *encoderState, v reflect.Value) bool
encUint16Slice
function
#
func encUint16Slice(state *encoderState, v reflect.Value) bool
encUint32Array
function
#
func encUint32Array(state *encoderState, v reflect.Value) bool
encUint32Slice
function
#
func encUint32Slice(state *encoderState, v reflect.Value) bool
encUint64Array
function
#
func encUint64Array(state *encoderState, v reflect.Value) bool
encUint64Slice
function
#
func encUint64Slice(state *encoderState, v reflect.Value) bool
encUint8Array
function
#
encUint8Array encodes the byte array referenced by v.
Byte arrays are encoded as an unsigned count followed by the raw bytes.
func encUint8Array(i *encInstr, state *encoderState, v reflect.Value)
encUintArray
function
#
func encUintArray(state *encoderState, v reflect.Value) bool
encUintSlice
function
#
func encUintSlice(state *encoderState, v reflect.Value) bool
encUintptrArray
function
#
func encUintptrArray(state *encoderState, v reflect.Value) bool
encUintptrSlice
function
#
func encUintptrSlice(state *encoderState, v reflect.Value) bool
encode
method
#
func (enc *Encoder) encode(b *encBuffer, value reflect.Value, ut *userTypeInfo)
encodeArray
method
#
encodeArray encodes an array.
func (enc *Encoder) encodeArray(b *encBuffer, value reflect.Value, op encOp, elemIndir int, length int, helper encHelper)
encodeGobEncoder
method
#
encodeGobEncoder encodes a value that implements the GobEncoder interface.
The data is sent as a byte array.
func (enc *Encoder) encodeGobEncoder(b *encBuffer, ut *userTypeInfo, v reflect.Value)
encodeInt
method
#
encodeInt writes an encoded signed integer to state.w.
The low bit of the encoding says whether to bit complement the (other bits of the)
uint to recover the int.
func (state *encoderState) encodeInt(i int64)
encodeInterface
method
#
encodeInterface encodes the interface value iv.
To send an interface, we send a string identifying the concrete type, followed
by the type identifier (which might require defining that type right now), followed
by the concrete value. A nil value gets sent as the empty string for the name,
followed by no value.
func (enc *Encoder) encodeInterface(b *encBuffer, iv reflect.Value)
encodeMap
method
#
encodeMap encodes a map as unsigned count followed by key:value pairs.
func (enc *Encoder) encodeMap(b *encBuffer, mv reflect.Value, keyOp encOp, elemOp encOp, keyIndir int, elemIndir int)
encodeReflectValue
function
#
encodeReflectValue is a helper for maps. It encodes the value v.
func encodeReflectValue(state *encoderState, v reflect.Value, op encOp, indir int)
encodeSingle
method
#
encodeSingle encodes a single top-level non-struct value.
func (enc *Encoder) encodeSingle(b *encBuffer, engine *encEngine, value reflect.Value)
encodeStruct
method
#
encodeStruct encodes a single struct value.
func (enc *Encoder) encodeStruct(b *encBuffer, engine *encEngine, value reflect.Value)
encodeUint
method
#
encodeUint writes an encoded unsigned integer to state.b.
func (state *encoderState) encodeUint(x uint64)
error_
function
#
error_ wraps the argument error and uses it as the argument to panic.
func error_(err error)
errorf
function
#
errorf is like error_ but takes Printf-style arguments to construct an error.
It always prefixes the message with "gob: ".
func errorf(format string, args ...any)
fieldValue
method
#
fieldValue prints a value of any type, such as a struct field.
FieldValue:
builtinValue | ArrayValue | MapValue | SliceValue | StructValue | InterfaceValue
func (deb *debugger) fieldValue(indent tab, id typeId)
float32FromBits
function
#
float32FromBits decodes an unsigned integer, treats it as a 32-bit floating-point
number, and returns it. It's a helper function for float32 and complex64.
It returns a float64 because that's what reflection needs, but its return
value is known to be accurately representable in a float32.
func float32FromBits(u uint64, ovfl error) float64
float64FromBits
function
#
Floating-point numbers are transmitted as uint64s holding the bits
of the underlying representation. They are sent byte-reversed, with
the exponent end coming out first, so integer floating point numbers
(for example) transmit more compactly. This routine does the
unswizzling.
func float64FromBits(u uint64) float64
floatBits
function
#
floatBits returns a uint64 holding the bits of a floating-point number.
Floating-point numbers are transmitted as uint64s holding the bits
of the underlying representation. They are sent byte-reversed, with
the exponent end coming out first, so integer floating point numbers
(for example) transmit more compactly. This routine does the
swizzling.
func floatBits(f float64) uint64
freeDecoderState
method
#
func (dec *Decoder) freeDecoderState(d *decoderState)
freeEncoderState
method
#
func (enc *Encoder) freeEncoderState(e *encoderState)
getBaseType
function
#
getBaseType returns the Gob type describing the given reflect.Type's base type.
typeLock must be held.
func getBaseType(name string, rt reflect.Type) (gobType, error)
getDecEnginePtr
method
#
getDecEnginePtr returns the engine for the specified type.
func (dec *Decoder) getDecEnginePtr(remoteId typeId, ut *userTypeInfo) (enginePtr **decEngine, err error)
getEncEngine
function
#
getEncEngine returns the engine to compile the type.
func getEncEngine(ut *userTypeInfo, building map[*typeInfo]bool) *encEngine
getIgnoreEnginePtr
method
#
getIgnoreEnginePtr returns the engine for the specified type when the value is to be discarded.
func (dec *Decoder) getIgnoreEnginePtr(wireId typeId) (enginePtr **decEngine, err error)
getLength
method
#
getLength decodes the next uint and makes sure it is a possible
size for a data item that follows, which means it must fit in a
non-negative int and fit in the buffer.
func (state *decoderState) getLength() (int, bool)
getType
function
#
getType returns the Gob type describing the given reflect.Type.
Should be called only when handling GobEncoders/Decoders,
which may be pointers. All other types are handled through the
base type, never a pointer.
typeLock must be held.
func getType(name string, ut *userTypeInfo, rt reflect.Type) (gobType, error)
getTypeInfo
function
#
func getTypeInfo(ut *userTypeInfo) (*typeInfo, error)
gobDecodeOpFor
method
#
gobDecodeOpFor returns the op for a type that is known to implement
GobDecoder.
func (dec *Decoder) gobDecodeOpFor(ut *userTypeInfo) *decOp
gobEncodeOpFor
function
#
gobEncodeOpFor returns the op for a type that is known to implement GobEncoder.
func gobEncodeOpFor(ut *userTypeInfo) (*encOp, int)
gobEncoderValue
method
#
GobEncoderValue:
uint(n) byte*n
func (deb *debugger) gobEncoderValue(indent tab, id typeId)
gobStream
method
#
GobStream:
DelimitedMessage* (until EOF)
func (deb *debugger) gobStream()
gobType
method
#
func (t typeId) gobType() gobType
growSlice
function
#
growSlice is called for a slice that we only partially allocated,
to grow it up to length.
func growSlice(v reflect.Value, ps *[]E, length int)
id
method
#
func (t *CommonType) id() typeId
idToType
function
#
func idToType(id typeId) gobType
ignoreArray
method
#
ignoreArray discards the data for an array value with no destination.
func (dec *Decoder) ignoreArray(state *decoderState, elemOp decOp, length int)
ignoreArrayHelper
method
#
ignoreArrayHelper does the work for discarding arrays and slices.
func (dec *Decoder) ignoreArrayHelper(state *decoderState, elemOp decOp, length int)
ignoreGobDecoder
method
#
ignoreGobDecoder discards the data for a GobDecoder value with no destination.
func (dec *Decoder) ignoreGobDecoder(state *decoderState)
ignoreInterface
method
#
ignoreInterface discards the data for an interface value with no destination.
func (dec *Decoder) ignoreInterface(state *decoderState)
ignoreMap
method
#
ignoreMap discards the data for a map value with no destination.
func (dec *Decoder) ignoreMap(state *decoderState, keyOp decOp, elemOp decOp)
ignoreSingle
method
#
ignoreSingle discards the data for a top-level non-struct value with no
destination. It's used when calling Decode with a nil value.
func (dec *Decoder) ignoreSingle(engine *decEngine)
ignoreSlice
method
#
ignoreSlice skips over the data for a slice value with no destination.
func (dec *Decoder) ignoreSlice(state *decoderState, elemOp decOp)
ignoreStruct
method
#
ignoreStruct discards the data for a struct with no destination.
func (dec *Decoder) ignoreStruct(engine *decEngine)
ignoreTwoUints
function
#
ignoreTwoUints discards a uint value with no destination. It's used to skip
complex values.
func ignoreTwoUints(i *decInstr, state *decoderState, v reflect.Value)
ignoreUint
function
#
ignoreUint discards a uint value with no destination.
func ignoreUint(i *decInstr, state *decoderState, v reflect.Value)
ignoreUint8Array
function
#
ignoreUint8Array skips over the data for a byte slice value with no destination.
func ignoreUint8Array(i *decInstr, state *decoderState, value reflect.Value)
implementsInterface
function
#
implementsInterface reports whether the type implements the
gobEncoder/gobDecoder interface.
It also returns the number of indirections required to get to the
implementation.
func implementsInterface(typ reflect.Type, gobEncDecType reflect.Type) (success bool, indir int8)
init
method
#
func (a *arrayType) init(elem gobType, len int)
init
function
#
Init installs the debugging facility. If this file is not compiled in the
package, the tests in codec_test.go are no-ops.
func init()
init
function
#
func init()
init
method
#
func (s *sliceType) init(elem gobType)
init
method
#
func (m *mapType) init(key gobType, elem gobType)
init
function
#
func init()
init
function
#
func init()
int
method
#
int returns the signed int at the input point, as an int (not int64).
func (deb *debugger) int() int
int64
method
#
int64 decodes and returns the next integer, which must be present.
Don't call this if you could be at EOF.
func (deb *debugger) int64() int64
interfaceValue
method
#
InterfaceValue:
NilInterfaceValue | NonNilInterfaceValue
func (deb *debugger) interfaceValue(indent tab)
isExported
function
#
isExported reports whether this is an exported - upper case - name.
func isExported(name string) bool
isSent
function
#
isSent reports whether this struct field is to be transmitted.
It will be transmitted only if it is exported and not a chan or func field
or pointer to chan or func.
func isSent(field *reflect.StructField) bool
loadBlock
method
#
loadBlock preps us to read a message
of the length specified next in the input. It returns
the length of the block. The argument tells whether
an EOF is acceptable now. If it is and one is found,
the return value is negative.
func (deb *debugger) loadBlock(eofOK bool) int
lookupTypeInfo
function
#
func lookupTypeInfo(rt reflect.Type) *typeInfo
mapValue
method
#
MapValue:
uint(n) (FieldValue FieldValue)*n [n (key, value) pairs]
func (deb *debugger) mapValue(indent tab, wire *wireType)
message
method
#
Message:
TypeSequence TypedValue
TypeSequence
(TypeDefinition DelimitedTypeDefinition*)?
DelimitedTypeDefinition:
uint(lengthOfTypeDefinition) TypeDefinition
TypedValue:
int(typeId) Value
func (deb *debugger) message(indent tab) bool
mustGetTypeInfo
function
#
Called only when a panic is acceptable and unexpected.
func mustGetTypeInfo(rt reflect.Type) *typeInfo
name
method
#
func (t *CommonType) name() string
name
method
#
Name returns the name of the type associated with the typeId.
func (t typeId) name() string
newArrayType
function
#
func newArrayType(name string) *arrayType
newDecoderState
method
#
We pass the bytes.Buffer separately for easier testing of the infrastructure
without requiring a full Decoder.
func (dec *Decoder) newDecoderState(buf *decBuffer) *decoderState
newEncoderState
method
#
func (enc *Encoder) newEncoderState(b *encBuffer) *encoderState
newGobEncoderType
function
#
func newGobEncoderType(name string) *gobEncoderType
newMapType
function
#
func newMapType(name string) *mapType
newPeekReader
function
#
newPeekReader returns a peekReader that wraps r.
func newPeekReader(r io.Reader) *peekReader
newSliceType
function
#
func newSliceType(name string) *sliceType
newStructType
function
#
func newStructType(name string) *structType
newTypeObject
function
#
newTypeObject allocates a gobType for the reflection type rt.
Unless ut represents a GobEncoder, rt should be the base type
of ut.
This is only called from the encoding side. The decoding side
works through typeIds and userTypeInfos alone.
func newTypeObject(name string, ut *userTypeInfo, rt reflect.Type) (gobType, error)
nextInt
method
#
func (dec *Decoder) nextInt() int64
nextUint
method
#
func (dec *Decoder) nextUint() uint64
nilInterfaceValue
method
#
NilInterfaceValue:
uint(0) [already read]
func (deb *debugger) nilInterfaceValue(indent tab) int
nonNilInterfaceValue
method
#
NonNilInterfaceValue:
ConcreteTypeName TypeSequence InterfaceContents
ConcreteTypeName:
uint(lengthOfName) [already read=n] name
InterfaceContents:
int(concreteTypeId) DelimitedValue
DelimitedValue:
uint(length) Value
func (deb *debugger) nonNilInterfaceValue(indent tab, nameLen int)
overflow
function
#
func overflow(name string) error
peek
method
#
peek returns as many bytes as possible from the unread
portion of the stream, up to the length of b.
func (p *peekReader) peek(b []byte) (n int, err error)
popWriter
method
#
popWriter pops the innermost writer.
func (enc *Encoder) popWriter()
print
method
#
func (t tab) print()
printBuiltin
method
#
printBuiltin prints a value not of a fundamental type, that is,
one whose type is known to gobs at bootstrap time.
func (deb *debugger) printBuiltin(indent tab, id typeId)
printCommonType
method
#
printCommonType prints a common type; used by printWireType.
func (deb *debugger) printCommonType(indent tab, kind string, common *CommonType)
printWireType
method
#
printWireType prints the contents of a wireType.
func (deb *debugger) printWireType(indent tab, wire *wireType)
pushWriter
method
#
pushWriter adds a writer to the encoder.
func (enc *Encoder) pushWriter(w io.Writer)
readMessage
method
#
readMessage reads the next nbytes bytes from the input.
func (dec *Decoder) readMessage(nbytes int)
recvMessage
method
#
recvMessage reads the next count-delimited item from the input. It is the converse
of Encoder.writeMessage. It returns false on EOF or other error reading the message.
func (dec *Decoder) recvMessage() bool
recvType
method
#
recvType loads the definition of a type.
func (dec *Decoder) recvType(id typeId)
registerBasics
function
#
func registerBasics()
safeString
method
#
func (s *structType) safeString(seen map[typeId]bool) string
safeString
method
#
func (a *arrayType) safeString(seen map[typeId]bool) string
safeString
method
#
func (m *mapType) safeString(seen map[typeId]bool) string
safeString
method
#
func (t *CommonType) safeString(seen map[typeId]bool) string
safeString
method
#
func (g *gobEncoderType) safeString(seen map[typeId]bool) string
safeString
method
#
func (s *sliceType) safeString(seen map[typeId]bool) string
sendActualType
method
#
sendActualType sends the requested type, without further investigation, unless
it's been sent before.
func (enc *Encoder) sendActualType(w io.Writer, state *encoderState, ut *userTypeInfo, actual reflect.Type) (sent bool)
sendType
method
#
sendType sends the type info to the other side, if necessary.
func (enc *Encoder) sendType(w io.Writer, state *encoderState, origt reflect.Type) (sent bool)
sendTypeDescriptor
method
#
sendTypeDescriptor makes sure the remote side knows about this type.
It will send a descriptor if this is the first time the type has been
sent.
func (enc *Encoder) sendTypeDescriptor(w io.Writer, state *encoderState, ut *userTypeInfo)
sendTypeId
method
#
sendTypeId sends the id, which must have already been defined.
func (enc *Encoder) sendTypeId(state *encoderState, ut *userTypeInfo)
setError
method
#
func (enc *Encoder) setError(err error)
setId
method
#
func (t *CommonType) setId(id typeId)
setTypeId
function
#
func setTypeId(typ gobType)
singletonValue
method
#
SingletonValue:
uint(0) FieldValue
func (deb *debugger) singletonValue(indent tab, id typeId)
sliceValue
method
#
SliceValue:
uint(n) (n FieldValue)
func (deb *debugger) sliceValue(indent tab, wire *wireType)
string
method
#
func (m *mapType) string() string
string
method
#
func (a *arrayType) string() string
string
method
#
func (s *structType) string() string
string
method
#
func (s *sliceType) string() string
string
method
#
string returns the string at the input point.
func (deb *debugger) string() string
string
method
#
func (t *CommonType) string() string
string
method
#
func (w *wireType) string() string
string
method
#
func (g *gobEncoderType) string() string
string
method
#
string returns the string representation of the type associated with the typeId.
func (t typeId) string() string
structValue
method
#
StructValue:
(uint(fieldDelta) FieldValue)*
func (deb *debugger) structValue(indent tab, id typeId)
toInt
function
#
toInt turns an encoded uint64 into an int, according to the marshaling rules.
func toInt(x uint64) int64
typeDefinition
method
#
TypeDefinition:
[int(-typeId) (already read)] encodingOfWireType
func (deb *debugger) typeDefinition(indent tab, id typeId)
typeId
method
#
typeId returns the type id at the input point.
func (deb *debugger) typeId() typeId
typeString
method
#
typeString returns a human-readable description of the type identified by remoteId.
func (dec *Decoder) typeString(remoteId typeId) string
uint
method
#
uint returns the unsigned int at the input point, as a uint (not uint64).
func (deb *debugger) uint() uint
uint64
method
#
uint64 returns and decodes the next unsigned integer, which must be present.
Don't call this if you could be at EOF.
TODO: handle errors better.
func (deb *debugger) uint64() uint64
update
method
#
update emits a field number and updates the state to record its value for delta encoding.
If the instruction pointer is nil, it does nothing
func (state *encoderState) update(instr *encInstr)
userType
function
#
userType returns, and saves, the information associated with user-provided type rt.
If the user type is not valid, it calls error.
func userType(rt reflect.Type) *userTypeInfo
valid
function
#
valid reports whether the value is valid and a non-nil pointer.
(Slices, maps, and chans take care of themselves.)
func valid(v reflect.Value) bool
validUserType
function
#
validUserType returns, and saves, the information associated with user-provided type rt.
If the user type is not valid, err will be non-nil. To be used when the error handler
is not set up.
func validUserType(rt reflect.Type) (*userTypeInfo, error)
value
method
#
Value:
SingletonValue | StructValue
func (deb *debugger) value(indent tab, id typeId)
writeByte
method
#
func (e *encBuffer) writeByte(c byte)
writeMessage
method
#
writeMessage sends the data item preceded by an unsigned count of its length.
func (enc *Encoder) writeMessage(w io.Writer, b *encBuffer)
writer
method
#
writer returns the innermost writer the encoder is using.
func (enc *Encoder) writer() io.Writer