transport := thrift.NewMemoryBuffer() protocol := thrift.NewTBinaryProtocolTransport(transport) foo := &MyStruct{Field1: "Hello", Field2: 42} if err := foo.Write(protocol); err != nil { log.Fatal("error writing struct:", err) } // send the bytes over the wire
transport := thrift.NewMemoryBuffer() protocol := thrift.NewTCompactProtocolTransport(transport) foo := &MyStruct{Field1: "Hello", Field2: 42} if err := foo.Write(protocol); err != nil { log.Fatal("error writing struct:", err) } // send the bytes over the wireThis example creates an instance of `TCompactProtocol` using a `MemoryBuffer` transport and writes a `MyStruct` instance to it. Overall, the `go.thrift` package provides a powerful set of tools for working with Thrift in Go.