In Go, I have a byte array data []byte
which I am trying to read into an object generated by Thrift. In C# the working code is as follows:
var request = new Request();
using (var transport = new TMemoryBuffer(data))
using (var protocol = new TBinaryProtocol(transport))
{
request.Read(protocol);
}
However in Go, it does not work:
request := app.NewRequest()
transport := thrift.TMemoryBuffer{
Buffer: bytes.NewBuffer(data),
}
protocol := thrift.NewTBinaryProtocolTransport(transport) // error here
request.Read(protocol)
The error it gives is:
cannot use memoryBuffer (type thrift.TMemoryBuffer) as type thrift.TTransport in argument to thrift.NewTBinaryProtocolTransport:
thrift.TMemoryBuffer does not implement thrift.TTransport (Close method has pointer receiver)
I am unsure of how to fix this, as TMemoryBuffer
does not seem to implement TTransport
and I can't find documentation of how TMemoryBuffer
should be used instead.