protocol := thrift.NewBinaryProtocol(transport) fieldType, fieldId, err := protocol.ReadFieldBegin() if err != nil { // handle error } fmt.Printf("Field type: %v, Field ID: %v", fieldType, fieldId)
protocol := thrift.NewCompactProtocol(transport) for { fieldType, fieldId, err := protocol.ReadFieldBegin() if err != nil { // handle error } if fieldType == thrift.STOP { break } // do something with the field }In this example, we create a new compact protocol instance and then loop through all the fields in the protocol. We use the ReadFieldBegin function to read the beginning of each field. If the field type is thrift.STOP, we break out of the loop. Otherwise, we do something with the field. Package Library: go git.apache.org.thrift.git.lib.go.thrift