Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrorTypeNotFit = errors.New("msg not proto.Message type")
Functions ¶
func SetDefaultEncodeType ¶
func SetDefaultEncodeType(n EncodeType)
SetDefaultEncodeType 修改默认编码类型,默认 encoding/gob 编码
Types ¶
type EncDecoder ¶
type EncDecoder interface { // Unmarshal 反序列化 Unmarshal(buf []byte, data interface{}) error // Marshal 序列化 Marshal(data interface{}) ([]byte, error) }
EncDecoder 应用层数据序列化方式
func GetEncoding ¶
func GetEncoding(n EncodeType) (EncDecoder, bool)
GetEncoding 获取指定的编码器 返回编码器和是否存在
type EncodeType ¶
type EncodeType int
EncodeType 编码器类型
const ( TypeNil EncodeType = iota TypeGPB TypeBinary TypeGob TypeJson TypeMax )
type Encoding ¶
type Encoding struct { DefaultEncodeType EncodeType // contains filtered or unexported fields }
Encoding 编码管理器
func (*Encoding) GetEncoding ¶
func (e *Encoding) GetEncoding(n EncodeType) (EncDecoder, bool)
GetEncoding 获取指定的编码器 返回编码器和是否存在
func (*Encoding) SetByteOrder ¶
SetByteOrder 修改字节序,默认小端序
func (*Encoding) TypeTest ¶
func (e *Encoding) TypeTest(msg interface{}) EncodeType
TypeTest 根据消息类型判断使用什么编码方式
Click to show internal directories.
Click to hide internal directories.