import ( "io" "git.apache.org/thrift.git/lib/go/thrift" ) func main() { protocolFactory := thrift.NewTBinaryProtocolFactoryDefault() transport, _ := thrift.NewTMemoryBufferLen(1024) protocol := protocolFactory.GetProtocol(transport) protocol.WriteString("Hello, world!") protocol.Flush() outBuffer := make([]byte, 1024) transport.Read(outBuffer) fmt.Println(string(outBuffer)) }
import ( "net" "git.apache.org/thrift.git/lib/go/thrift" ) func main() { protocolFactory := thrift.NewTBinaryProtocolFactoryDefault() socket, _ := net.DialTimeout("tcp", "localhost:9090", 5*time.Second) transport := thrift.NewTFramedTransport(socket) protocol := protocolFactory.GetProtocol(transport) // Protocol write operations protocol.Flush() }In this example, we create a new binary protocol object and a framed transport object that wraps a TCP socket. After performing some write operations on the protocol object, we call the Flush() method to immediately send the data to the remote endpoint on the TCP socket.