Documentation ¶
Index ¶
Constants ¶
View Source
const ( NilCodecId byte = 0 NilCodecName string = "" )
View Source
const ( NAME_JSON = "json" ID_JSON = 'j' )
json codec id
View Source
const ( NAME_PROTOBUF = "protobuf" ID_PROTOBUF = 'p' )
protobuf codec id
View Source
const ( NAME_STRING = "string" ID_STRING = 's' )
protobuf codec id
Variables ¶
View Source
var ( ErrInvalidLengthempty = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowempty = fmt.Errorf("proto: integer overflow") )
View Source
var Empty = new(empty)
Functions ¶
func ProtoMarshal ¶
func ProtoUnmarshal ¶
Types ¶
type Codec ¶
type Codec interface { // Id returns codec id. Id() byte // Name returns codec name. Name() string // Marshal returns the encoding of v. Marshal(v interface{}) ([]byte, error) // Unmarshal parses the encoded data and stores the result // in the value pointed to by v. Unmarshal(data []byte, v interface{}) error }
Codec makes Encoder and Decoder
type JsonCodec ¶
type JsonCodec struct{}
JsonCodec json codec
type ProtoCodec ¶
type ProtoCodec struct{}
ProtoCodec protobuf codec
func (ProtoCodec) Marshal ¶
func (ProtoCodec) Marshal(v interface{}) ([]byte, error)
Marshal returns the Protobuf encoding of v.
func (ProtoCodec) Unmarshal ¶
func (ProtoCodec) Unmarshal(data []byte, v interface{}) error
Unmarshal parses the Protobuf-encoded data and stores the result in the value pointed to by v.
type StringCodec ¶
type StringCodec struct{}
StringCodec string codec
func (StringCodec) Marshal ¶
func (StringCodec) Marshal(v interface{}) ([]byte, error)
Marshal returns the string encoding of v.
func (StringCodec) Unmarshal ¶
func (StringCodec) Unmarshal(data []byte, v interface{}) error
Unmarshal parses the string-encoded data and stores the result in the value pointed to by v.
Click to show internal directories.
Click to hide internal directories.