github.com/keybase/client/go@v0.0.0-20240309051027-028f7c731f8b/chat/flip/msgpack.go (about) 1 package flip 2 3 import ( 4 "github.com/keybase/go-codec/codec" 5 ) 6 7 func codecHandle() *codec.MsgpackHandle { 8 var mh codec.MsgpackHandle 9 mh.WriteExt = true 10 return &mh 11 } 12 13 func msgpackDecode(dst interface{}, src []byte) error { 14 h := codecHandle() 15 return codec.NewDecoderBytes(src, h).Decode(dst) 16 } 17 18 func msgpackEncode(src interface{}) ([]byte, error) { 19 h := codecHandle() 20 var ret []byte 21 err := codec.NewEncoderBytes(&ret, h).Encode(src) 22 if err != nil { 23 return nil, err 24 } 25 return ret, nil 26 }