Documentation
¶
Overview ¶
Package code implements encoding and decoding.
Index ¶
- func CheckBuffer(buf []byte, n uint64) []byte
- func DecodeBool(buf []byte, v *bool) uint64
- func DecodeBoolSlice(buf []byte, v *[]bool) uint64
- func DecodeBytes(buf []byte, v *[]byte) uint64
- func DecodeBytesSlice(buf []byte, v *[][]byte) uint64
- func DecodeFloat32(buf []byte, v *float32) uint64
- func DecodeFloat32Slice(buf []byte, v *[]float32) uint64
- func DecodeFloat64(buf []byte, v *float64) uint64
- func DecodeFloat64Slice(buf []byte, v *[]float64) uint64
- func DecodeString(buf []byte, v *string) uint64
- func DecodeStringSlice(buf []byte, v *[]string) uint64
- func DecodeUint16(buf []byte, v *uint16) uint64
- func DecodeUint16Slice(buf []byte, v *[]uint16) uint64
- func DecodeUint32(buf []byte, v *uint32) uint64
- func DecodeUint32Slice(buf []byte, v *[]uint32) uint64
- func DecodeUint64(buf []byte, v *uint64) uint64
- func DecodeUint64Slice(buf []byte, v *[]uint64) uint64
- func DecodeUint8(buf []byte, v *uint8) uint64
- func DecodeUint8Slice(buf []byte, v *[]uint8) uint64
- func DecodeVarint(buf []byte, v *uint64) uint64
- func DecodeVarintSlice(buf []byte, v *[]uint64) uint64
- func EncodeBool(buf []byte, v bool) uint64
- func EncodeBoolSlice(buf []byte, v []bool) uint64
- func EncodeBytes(buf []byte, v []byte) uint64
- func EncodeBytesSlice(buf []byte, v [][]byte) uint64
- func EncodeFloat32(buf []byte, v float32) uint64
- func EncodeFloat32Slice(buf []byte, v []float32) uint64
- func EncodeFloat64(buf []byte, v float64) uint64
- func EncodeFloat64Slice(buf []byte, v []float64) uint64
- func EncodeString(buf []byte, v string) uint64
- func EncodeStringSlice(buf []byte, v []string) uint64
- func EncodeUint16(buf []byte, v uint16) uint64
- func EncodeUint16Slice(buf []byte, v []uint16) uint64
- func EncodeUint32(buf []byte, v uint32) uint64
- func EncodeUint32Slice(buf []byte, v []uint32) uint64
- func EncodeUint64(buf []byte, v uint64) uint64
- func EncodeUint64Slice(buf []byte, v []uint64) uint64
- func EncodeUint8(buf []byte, v uint8) uint64
- func EncodeUint8Slice(buf []byte, v []uint8) uint64
- func EncodeVarint(buf []byte, v uint64) uint64
- func EncodeVarintSlice(buf []byte, v []uint64) uint64
- func GetTagFieldNumber(tag uint64) int
- func MakeTag(fieldNumber int, wireType WireType) uint64
- func MaxBoolBytes(v bool) uint64
- func MaxBoolSliceBytes(v []bool) uint64
- func MaxBytesBytes(v []byte) uint64
- func MaxBytesSliceBytes(v [][]byte) uint64
- func MaxFloat32Bytes(v float32) uint64
- func MaxFloat32SliceBytes(v []float32) uint64
- func MaxFloat64Bytes(v float64) uint64
- func MaxFloat64SliceBytes(v []float64) uint64
- func MaxStringBytes(v string) uint64
- func MaxStringSliceBytes(v []string) uint64
- func MaxUint16Bytes(v uint16) uint64
- func MaxUint16SliceBytes(v []uint16) uint64
- func MaxUint32Bytes(v uint32) uint64
- func MaxUint32SliceBytes(v []uint32) uint64
- func MaxUint64Bytes(v uint64) uint64
- func MaxUint64SliceBytes(v []uint64) uint64
- func MaxUint8Bytes(v uint8) uint64
- func MaxUint8SliceBytes(v []uint8) uint64
- func MaxVarintBytes(v uint64) uint64
- func MaxVarintSliceBytes(v []uint64) uint64
- func SizeofBool(v bool) uint64
- func SizeofBoolSlice(v []bool) uint64
- func SizeofBytes(v []byte) uint64
- func SizeofBytesSlice(v [][]byte) uint64
- func SizeofFloat32(v float32) uint64
- func SizeofFloat32Slice(v []float32) uint64
- func SizeofFloat64(v float64) uint64
- func SizeofFloat64Slice(v []float64) uint64
- func SizeofString(v string) uint64
- func SizeofStringSlice(v []string) uint64
- func SizeofUint16(v uint16) uint64
- func SizeofUint16Slice(v []uint16) uint64
- func SizeofUint32(v uint32) uint64
- func SizeofUint32Slice(v []uint32) uint64
- func SizeofUint64(v uint64) uint64
- func SizeofUint64Slice(v []uint64) uint64
- func SizeofUint8(v uint8) uint64
- func SizeofUint8Slice(v []uint8) uint64
- func SizeofVarint(v uint64) uint64
- func SizeofVarintSlice(v []uint64) uint64
- type WireType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckBuffer ¶
CheckBuffer checks the capacity of buf and returns the buffer of sufficient size. If the buf is too small, CheckBuffer will make a new buffer.
func DecodeBool ¶
DecodeBool decodes a bool from buf, stores the result in the value pointed to by v and returns the number of bytes read (> 0). If the buffer is not from EncodeBool, DecodeBool will panic.
func DecodeBoolSlice ¶
DecodeBoolSlice decodes a []bool from buf, stores the result in the value pointed to by v and returns the number of bytes read (> 0). If the buffer is not from EncodeBoolSlice, DecodeBoolSlice will panic.
func DecodeBytes ¶
DecodeBytes decodes a []byte from buf, stores the result in the value pointed to by v and returns the number of bytes read (> 0). If the buffer is not from EncodeBytes, DecodeBytes will panic.
func DecodeBytesSlice ¶
DecodeBytesSlice decodes a [][]byte from buf, stores the result in the value pointed to by v and returns the number of bytes read (> 0). If the buffer is not from EncodeBytesSlice, DecodeBytesSlice will panic.
func DecodeFloat32 ¶
DecodeFloat32 decodes a float32 from buf, stores the result in the value pointed to by v and returns the number of bytes read (> 0). If the buffer is not from EncodeFloat32, DecodeFloat32 will panic.
func DecodeFloat32Slice ¶
DecodeFloat32Slice decodes a []float32 from buf, stores the result in the value pointed to by v and returns the number of bytes read (> 0). If the buffer is not from EncodeFloat32Slice, DecodeFloat32Slice will panic.
func DecodeFloat64 ¶
DecodeFloat64 decodes a float64 from buf, stores the result in the value pointed to by v and returns the number of bytes read (> 0). If the buffer is not from EncodeFloat64, DecodeFloat64 will panic.
func DecodeFloat64Slice ¶
DecodeFloat64Slice decodes a uint64 from buf, stores the result in the value pointed to by v and returns the number of bytes read (> 0). If the buffer is not from EncodeFloat64Slice, DecodeFloat64Slice will panic.
func DecodeString ¶
DecodeString decodes a string from buf, stores the result in the value pointed to by v and returns the number of bytes read (> 0). If the buffer is not from EncodeString, DecodeString will panic.
func DecodeStringSlice ¶
DecodeStringSlice decodes a []string from buf, stores the result in the value pointed to by v and returns the number of bytes read (> 0). If the buffer is not from EncodeStringSlice, DecodeStringSlice will panic.
func DecodeUint16 ¶
DecodeUint16 decodes a uint16 from buf, stores the result in the value pointed to by v and returns the number of bytes read (> 0). If the buffer is not from EncodeUint16, DecodeUint16 will panic.
func DecodeUint16Slice ¶
DecodeUint16Slice decodes a uint64 from buf, stores the result in the value pointed to by v and returns the number of bytes read (> 0). If the buffer is not from EncodeUint16Slice, DecodeUint16Slice will panic.
func DecodeUint32 ¶
DecodeUint32 decodes a uint32 from buf, stores the result in the value pointed to by v and returns the number of bytes read (> 0). If the buffer is not from EncodeUint32, DecodeUint32 will panic.
func DecodeUint32Slice ¶
DecodeUint32Slice decodes a []uint32 from buf, stores the result in the value pointed to by v and returns the number of bytes read (> 0). If the buffer is not from EncodeUint32Slice, DecodeUint32Slice will panic.
func DecodeUint64 ¶
DecodeUint64 decodes a uint64 from buf, stores the result in the value pointed to by v and returns the number of bytes read (> 0). If the buffer is not from EncodeUint64, DecodeUint64 will panic.
func DecodeUint64Slice ¶
DecodeUint64Slice decodes a []uint64 from buf, stores the result in the value pointed to by v and returns the number of bytes read (> 0). If the buffer is not from EncodeUint64Slice, DecodeUint64Slice will panic.
func DecodeUint8 ¶
DecodeUint8 decodes a uint8 from buf, stores the result in the value pointed to by v and returns the number of bytes read (> 0). If the buffer is not from EncodeUint8, DecodeUint8 will panic.
func DecodeUint8Slice ¶
DecodeUint8Slice decodes a []uint8 from buf, stores the result in the value pointed to by v and returns the number of bytes read (> 0). If the buffer is not from EncodeUint8Slice, DecodeUint8Slice will panic.
func DecodeVarint ¶
DecodeVarint decodes a uint64 from buf, stores the result in the value pointed to by v and returns the number of bytes read (> 0). If the buffer is not from EncodeVarint, DecodeVarint will panic.
func DecodeVarintSlice ¶
DecodeVarintSlice decodes a []uint64 from buf, stores the result in the value pointed to by v and returns the number of bytes read (> 0). If the buffer is not from EncodeVarintSlice, DecodeVarintSlice will panic.
func EncodeBool ¶
EncodeBool encodes a bool into buf and returns the number of bytes written. If the buffer is too small, EncodeBool will panic.
func EncodeBoolSlice ¶
EncodeBoolSlice encodes a []bool into buf and returns the number of bytes written. If the buffer is too small, EncodeBoolSlice will panic.
func EncodeBytes ¶
EncodeBytes encodes a []byte into buf and returns the number of bytes written. If the buffer is too small, EncodeBytes will panic.
func EncodeBytesSlice ¶
EncodeBytesSlice encodes a buf [][]byte into buf and returns the number of bytes written. If the buffer is too small, EncodeBytesSlice will panic.
func EncodeFloat32 ¶
EncodeFloat32 encodes a float32 into buf and returns the number of bytes written. If the buffer is too small, EncodeFloat32 will panic.
func EncodeFloat32Slice ¶
EncodeFloat32Slice encodes a []float32 into buf and returns the number of bytes written. If the buffer is too small, EncodeFloat32Slice will panic.
func EncodeFloat64 ¶
EncodeFloat64 encodes a float64 into buf and returns the number of bytes written. If the buffer is too small, EncodeFloat64 will panic.
func EncodeFloat64Slice ¶
EncodeFloat64Slice encodes a []float64 into buf and returns the number of bytes written. If the buffer is too small, EncodeFloat64Slice will panic.
func EncodeString ¶
EncodeString encodes a string into buf and returns the number of bytes written. If the buffer is too small, EncodeString will panic.
func EncodeStringSlice ¶
EncodeStringSlice encodes a []string into buf and returns the number of bytes written. If the buffer is too small, EncodeStringSlice will panic.
func EncodeUint16 ¶
EncodeUint16 encodes a uint16 into buf and returns the number of bytes written. If the buffer is too small, EncodeUint16 will panic.
func EncodeUint16Slice ¶
EncodeUint16Slice encodes a []uint16 into buf and returns the number of bytes written. If the buffer is too small, EncodeUint16Slice will panic.
func EncodeUint32 ¶
EncodeUint32 encodes a uint32 into buf and returns the number of bytes written. If the buffer is too small, EncodeUint32 will panic.
func EncodeUint32Slice ¶
EncodeUint32Slice encodes a []uint32 into buf and returns the number of bytes written. If the buffer is too small, EncodeUint32Slice will panic.
func EncodeUint64 ¶
EncodeUint64 encodes a uint64 into buf and returns the number of bytes written. If the buffer is too small, EncodeUint64 will panic.
func EncodeUint64Slice ¶
EncodeUint64Slice encodes a []uint64 into buf and returns the number of bytes written. If the buffer is too small, EncodeUint64Slice will panic.
func EncodeUint8 ¶
EncodeUint8 encodes a uint8 into buf and returns the number of bytes written. If the buffer is too small, EncodeUint8 will panic.
func EncodeUint8Slice ¶
EncodeUint8Slice encodes a []uint8 into buf and returns the number of bytes written. If the buffer is too small, EncodeUint8Slice will panic.
func EncodeVarint ¶
EncodeVarint encodes a uint64 into buf and returns the number of bytes written. If the buffer is too small, EncodeVarint will panic.
func EncodeVarintSlice ¶
EncodeVarintSlice encodes a buf []uint64 into buf and returns the number of bytes written. If the buffer is too small, EncodeVarintSlice will panic.
func GetTagFieldNumber ¶
GetTagFieldNumber given a tag value, returns the field number (the upper 29 bits).
func MaxBoolSliceBytes ¶
MaxBoolSliceBytes returns maximum length of a []bool.
func MaxBytesBytes ¶
MaxBytesBytes returns maximum length of a []byte.
func MaxBytesSliceBytes ¶
MaxBytesSliceBytes returns maximum length of a [][]byte.
func MaxFloat32Bytes ¶
MaxFloat32Bytes returns maximum length of a float32.
func MaxFloat32SliceBytes ¶
MaxFloat32SliceBytes returns maximum length of a []float32.
func MaxFloat64Bytes ¶
MaxFloat64Bytes returns maximum length of a float64.
func MaxFloat64SliceBytes ¶
MaxFloat64SliceBytes returns maximum length of a []float64.
func MaxStringBytes ¶
MaxStringBytes returns maximum length of a string.
func MaxStringSliceBytes ¶
MaxStringSliceBytes returns maximum length of a []string.
func MaxUint16Bytes ¶
MaxUint16Bytes returns maximum length of a uint16.
func MaxUint16SliceBytes ¶
MaxUint16SliceBytes returns maximum length of a []uint16.
func MaxUint32Bytes ¶
MaxUint32Bytes returns maximum length of a uint32.
func MaxUint32SliceBytes ¶
MaxUint32SliceBytes returns maximum length of a []uint32.
func MaxUint64Bytes ¶
MaxUint64Bytes returns maximum length of a uint64.
func MaxUint64SliceBytes ¶
MaxUint64SliceBytes returns maximum length of a []uint64.
func MaxUint8Bytes ¶
MaxUint8Bytes returns maximum length of a uint8.
func MaxUint8SliceBytes ¶
MaxUint8SliceBytes returns maximum length of a []uint8.
func MaxVarintBytes ¶
MaxVarintBytes returns maximum length of a varint.
func MaxVarintSliceBytes ¶
MaxVarintSliceBytes returns maximum length of a []varint.
func SizeofBool ¶
SizeofBool takes a bool and returns the number of bytes.
func SizeofBoolSlice ¶
SizeofBoolSlice takes a []bool and returns the number of bytes.
func SizeofBytes ¶
SizeofBytes takes a []byte and returns the number of bytes.
func SizeofBytesSlice ¶
SizeofBytesSlice takes a [][]byte and returns the number of bytes.
func SizeofFloat32 ¶
SizeofFloat32 takes a float32 and returns the number of bytes.
func SizeofFloat32Slice ¶
SizeofFloat32Slice takes a []float32 and returns the number of bytes.
func SizeofFloat64 ¶
SizeofFloat64 takes a float64 and returns the number of bytes.
func SizeofFloat64Slice ¶
SizeofFloat64Slice takes a []float64 and returns the number of bytes.
func SizeofString ¶
SizeofString takes a string and returns the number of bytes.
func SizeofStringSlice ¶
SizeofStringSlice takes a []string and returns the number of bytes.
func SizeofUint16 ¶
SizeofUint16 takes a uint16 and returns the number of bytes.
func SizeofUint16Slice ¶
SizeofUint16Slice takes a []uint16 and returns the number of bytes.
func SizeofUint32 ¶
SizeofUint32 takes a uint32 and returns the number of bytes.
func SizeofUint32Slice ¶
SizeofUint32Slice takes a []uint32 and returns the number of bytes.
func SizeofUint64 ¶
SizeofUint64 takes a uint64 and returns the number of bytes.
func SizeofUint64Slice ¶
SizeofUint64Slice takes a []uint64 and returns the number of bytes.
func SizeofUint8 ¶
SizeofUint8 takes a uint8 and returns the number of bytes.
func SizeofUint8Slice ¶
SizeofUint8Slice takes a []uint8 and returns the number of bytes.
func SizeofVarint ¶
SizeofVarint takes a uint64 and returns the number of bytes.
func SizeofVarintSlice ¶
SizeofVarintSlice takes a []uint64 and returns the number of bytes.
Types ¶
type WireType ¶
type WireType uint8
WireType defines the type of wire.
const ( //Varint is used for int32, int64, uint32, uint64, sint32, sint64, bool, enum. Varint WireType = 0 //Fixed64 is used for fixed64, sfixed64, double. Fixed64 WireType = 1 //LengthDelimited is used for string, bytes, embedded messages, packed repeated fields. LengthDelimited WireType = 2 //StartGroup is used for groups (deprecated). StartGroup WireType = 3 //EndGroup is used for groups (deprecated). EndGroup WireType = 4 //Fixed32 is used for fixed32, sfixed32, float. Fixed32 WireType = 5 //Invalid is an invalid type of wire. Invalid WireType = 255 )
func GetTagWireType ¶
GetTagWireType given a tag value, returns the wire type (lower 3 bits).
func GetWireType ¶
func GetWireType(i interface{}) (c WireType)
GetWireType given an interface, returns the wire type.