const uint64Size … type encHelper … type encoderState … type encBuffer … var encBufferPool … func (e *encBuffer) writeByte(c byte) { … } func (e *encBuffer) Write(p []byte) (int, error) { … } func (e *encBuffer) WriteString(s string) { … } func (e *encBuffer) Len() int { … } func (e *encBuffer) Bytes() []byte { … } func (e *encBuffer) Reset() { … } func (enc *Encoder) newEncoderState(b *encBuffer) *encoderState { … } func (enc *Encoder) freeEncoderState(e *encoderState) { … } // encodeUint writes an encoded unsigned integer to state.b. func (state *encoderState) encodeUint(x uint64) { … } // 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) { … } type encOp … type encInstr … // 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) { … } // encIndirect dereferences pv indir times and returns the result. func encIndirect(pv reflect.Value, indir int) reflect.Value { … } // encBool encodes the bool referenced by v as an unsigned 0 or 1. func encBool(i *encInstr, state *encoderState, v reflect.Value) { … } // encInt encodes the signed integer (int int8 int16 int32 int64) referenced by v. func encInt(i *encInstr, state *encoderState, v reflect.Value) { … } // encUint encodes the unsigned integer (uint uint8 uint16 uint32 uint64 uintptr) referenced by v. func encUint(i *encInstr, state *encoderState, v reflect.Value) { … } // 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 { … } // encFloat encodes the floating point value (float32 float64) referenced by v. func encFloat(i *encInstr, state *encoderState, v reflect.Value) { … } // 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) { … } // 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) { … } // 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) { … } // encStructTerminator encodes the end of an encoded struct // as delta field number of 0. func encStructTerminator(i *encInstr, state *encoderState, v reflect.Value) { … } type encEngine … const singletonField … // 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 { … } // encodeSingle encodes a single top-level non-struct value. func (enc *Encoder) encodeSingle(b *encBuffer, engine *encEngine, value reflect.Value) { … } // encodeStruct encodes a single struct value. func (enc *Encoder) encodeStruct(b *encBuffer, engine *encEngine, value reflect.Value) { … } // encodeArray encodes an array. func (enc *Encoder) encodeArray(b *encBuffer, value reflect.Value, op encOp, elemIndir int, length int, helper encHelper) { … } // encodeReflectValue is a helper for maps. It encodes the value v. func encodeReflectValue(state *encoderState, v reflect.Value, op encOp, indir int) { … } // encodeMap encodes a map as unsigned count followed by key:value pairs. func (enc *Encoder) encodeMap(b *encBuffer, mv reflect.Value, keyOp, elemOp encOp, keyIndir, elemIndir int) { … } // 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) { … } // 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) { … } var encOpTable … // 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) { … } // gobEncodeOpFor returns the op for a type that is known to implement GobEncoder. func gobEncodeOpFor(ut *userTypeInfo) (*encOp, int) { … } // compileEnc returns the engine to compile the type. func compileEnc(ut *userTypeInfo, building map[*typeInfo]bool) *encEngine { … } // getEncEngine returns the engine to compile the type. func getEncEngine(ut *userTypeInfo, building map[*typeInfo]bool) *encEngine { … } func buildEncEngine(info *typeInfo, ut *userTypeInfo, building map[*typeInfo]bool) *encEngine { … } func (enc *Encoder) encode(b *encBuffer, value reflect.Value, ut *userTypeInfo) { … }