Beispiel #1
0
// newCodecMsgpackHelper constructs a new CodecMsgpack that may or may
// not handle unknown fields.
func newCodecMsgpackHelper(handleUnknownFields bool) *CodecMsgpack {
	handle := codec.MsgpackHandle{}
	handle.Canonical = true
	handle.WriteExt = true
	handle.DecodeUnknownFields = handleUnknownFields
	handle.EncodeUnknownFields = handleUnknownFields

	// save a codec that doesn't write extensions, so that we can just
	// call Encode/Decode when we want to (de)serialize extension
	// types.
	handleNoExt := handle
	handleNoExt.WriteExt = false
	extCodec := &CodecMsgpack{&handleNoExt, nil}
	return &CodecMsgpack{&handle, extCodec}
}
Beispiel #2
0
func codecHandle() *codec.MsgpackHandle {
	var mh codec.MsgpackHandle
	mh.WriteExt = true
	return &mh
}