这是我在Go中尝试做的JavaScript版本。
let next = TBufferedTransport.receiver(data => {
let proto = new TCompactProtocol(data)
let ae = new AnalyticEventBatch()
ae.read(proto)
});
使用Go,我无法让Thrift解码有效载荷 - 我应该怎么做?
答案 0 :(得分:4)
var data []byte //that's the byte array you received
transp := &TMemoryBuffer{Buffer: bytes.NewBuffer(data)}
proto := NewTCompactProtocol(transp)
ae := NewAnalyticEventBatch()
ae.Read(proto)
如果你可以直接从文件/套接字读取它会更干净。那么你只需要节俭StreamTransport