Documentation
¶
Overview ¶
proto protobuf编解码的简单实现,限制是仅仅支持工具生成协议,好处是不依赖官方库,而且代码量也少
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotSupport = errors.New("protobuf not support")
Functions ¶
func Marshal ¶
Marshal takes a protocol buffer message and encodes it into the wire format, returning the data. This is the main entry point.
func Unmarshal ¶
Unmarshal parses the protocol buffer representation in buf and places the decoded result in pb. If the struct underlying pb does not match the data in buf, the results can be unpredictable.
Unmarshal resets pb before starting to unmarshal, so any existing data in pb is always removed. Use UnmarshalMerge to preserve and append to existing data.
Types ¶
type Message ¶
type Message interface { Reset() String() string ProtoMessage() }
Text is implemented by generated protocol buffer messages.
type Unmarshaler ¶
Unmarshaler is the interface representing objects that can unmarshal themselves. The argument points to data that may be overwritten, so implementations should not keep references to the buffer. Unmarshal implementations should not clear the receiver. Any unmarshaled data should be merged into the receiver. Callers of Unmarshal that do not want to retain existing data should Reset the receiver before calling Unmarshal.