本文整理匯總了Golang中github.com/apesternikov/thrift4go/lib/go/src/thrift.TProtocol.ReadStructBegin方法的典型用法代碼示例。如果您正苦於以下問題:Golang TProtocol.ReadStructBegin方法的具體用法?Golang TProtocol.ReadStructBegin怎麽用?Golang TProtocol.ReadStructBegin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/apesternikov/thrift4go/lib/go/src/thrift.TProtocol
的用法示例。
在下文中一共展示了TProtocol.ReadStructBegin方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Read
func (p *MyMethodResult) Read(iprot thrift.TProtocol) (err thrift.TProtocolException) {
_, err = iprot.ReadStructBegin()
if err != nil {
return thrift.NewTProtocolExceptionReadStruct(p.ThriftName(), err)
}
for {
fieldName, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if fieldId < 0 {
fieldId = int16(tstructMyMethodResult.FieldIdFromFieldName(fieldName))
fieldTypeId = tstructMyMethodResult.FieldFromFieldName(fieldName).TypeId()
}
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
if fieldTypeId == thrift.STOP {
break
}
switch fieldId {
default:
err = iprot.Skip(fieldTypeId)
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
} //switch
err = iprot.ReadFieldEnd()
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
}
err = iprot.ReadStructEnd()
if err != nil {
return thrift.NewTProtocolExceptionReadStruct(p.ThriftName(), err)
}
return err
}
示例2: Read
func (p *InvalidOperation) Read(iprot thrift.TProtocol) (err thrift.TProtocolException) {
_, err = iprot.ReadStructBegin()
if err != nil {
return thrift.NewTProtocolExceptionReadStruct(p.ThriftName(), err)
}
for {
fieldName, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if fieldId < 0 {
fieldId = int16(tstructInvalidOperation.FieldIdFromFieldName(fieldName))
fieldTypeId = tstructInvalidOperation.FieldFromFieldName(fieldName).TypeId()
}
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
if fieldTypeId == thrift.STOP {
break
}
switch fieldId {
case 1: //i32
if fieldTypeId == thrift.I32 {
err = p.readField1(iprot)
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
} else {
err = iprot.Skip(fieldTypeId)
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
}
case 2: //string
if fieldTypeId == thrift.STRING {
err = p.readField2(iprot)
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
} else {
err = iprot.Skip(fieldTypeId)
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
}
default:
err = iprot.Skip(fieldTypeId)
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
} //switch
err = iprot.ReadFieldEnd()
if err != nil {
return thrift.NewTProtocolExceptionReadField(int(fieldId), fieldName, p.ThriftName(), err)
}
}
err = iprot.ReadStructEnd()
if err != nil {
return thrift.NewTProtocolExceptionReadStruct(p.ThriftName(), err)
}
return err
}