如何在 Go 中解码 Apache Thrift 负载?
How do I decode an Apache Thrift payload in Go?
这是我在 Go 中尝试做的工作 JavaScript 版本。
let next = TBufferedTransport.receiver(data => {
let proto = new TCompactProtocol(data)
let ae = new AnalyticEventBatch()
ae.read(proto)
});
使用 Go,我无法让 Thrift 解码有效负载 - 我应该怎么办?
var data []byte //that's the byte array you received
transp := &TMemoryBuffer{Buffer: bytes.NewBuffer(data)}
proto := NewTCompactProtocol(transp)
ae := NewAnalyticEventBatch()
ae.Read(proto)
如果能直接从file/socket读取就更干净了。那么你只需要节俭StreamTransport
这是我在 Go 中尝试做的工作 JavaScript 版本。
let next = TBufferedTransport.receiver(data => {
let proto = new TCompactProtocol(data)
let ae = new AnalyticEventBatch()
ae.read(proto)
});
使用 Go,我无法让 Thrift 解码有效负载 - 我应该怎么办?
var data []byte //that's the byte array you received
transp := &TMemoryBuffer{Buffer: bytes.NewBuffer(data)}
proto := NewTCompactProtocol(transp)
ae := NewAnalyticEventBatch()
ae.Read(proto)
如果能直接从file/socket读取就更干净了。那么你只需要节俭StreamTransport