protocol := thrift.NewTBinaryProtocol(transport) fieldType := thrift.BOOL fieldID := 1 err := protocol.WriteFieldBegin("is_active", fieldType, fieldID)
type User struct { Name string `thrift:"name,1"` Email string `thrift:"email,2"` } user := User{"Alice", "[email protected]"} protocol := thrift.NewTBinaryProtocol(transport) fieldType := thrift.STRUCT fieldID := 1 err := protocol.WriteFieldBegin("user_info", fieldType, fieldID) if err == nil { err = user.Write(protocol) }In this example, we are creating a struct type User with two fields, Name and Email. We then write the User struct as a field using the WriteFieldBegin function. The field type is set to STRUCT, and the field ID is 1. The user object is then written to the protocol stream using the Write method. The package library for these examples is "git-wip-us.apache.org/repos/asf/thrift.git/lib/go/thrift".