Created
October 14, 2020 07:42
-
-
Save PureWhiteWu/296f2bdac6051e4052a68c2bb1de1c07 to your computer and use it in GitHub Desktop.
使用人工智能优化 Golang 编译器 —— 最新生成代码
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Code generated by x. DO NOT EDIT. | |
package x | |
import ( | |
"context" | |
"fmt" | |
"github.com/apache/thrift/lib/go/thrift" | |
) | |
type Example struct { | |
Data1 [][]int64 `thrift:"data1,1" json:"data1"` | |
Data2 map[int64][]int8 `thrift:"data2,2" json:"data2"` | |
Data3 []map[int64]int8 `thrift:"data3,3" json:"data3"` | |
} | |
func NewExample() *Example { | |
return &Example{} | |
} | |
func (p *Example) GetData1() [][]int64 { | |
return p.Data1 | |
} | |
func (p *Example) GetData2() map[int64][]int8 { | |
return p.Data2 | |
} | |
func (p *Example) GetData3() []map[int64]int8 { | |
return p.Data3 | |
} | |
func (p *Example) SetData1(val [][]int64) { | |
p.Data1 = val | |
} | |
func (p *Example) SetData2(val map[int64][]int8) { | |
p.Data2 = val | |
} | |
func (p *Example) SetData3(val []map[int64]int8) { | |
p.Data3 = val | |
} | |
var fieldIDToName_Example = map[int16]string{ | |
1: "data1", | |
2: "data2", | |
3: "data3", | |
} | |
func (p *Example) Read(iprot thrift.TProtocol) error { | |
var err error | |
var fieldTypeId thrift.TType | |
var fieldId int16 | |
if _, err = iprot.ReadStructBegin(); err != nil { | |
goto ReadStructBeginError | |
} | |
for { | |
_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() | |
if err != nil { | |
goto ReadFieldBeginError | |
} | |
if fieldTypeId == thrift.STOP { | |
break | |
} | |
switch fieldId { | |
case 1: | |
if fieldTypeId == thrift.LIST { | |
if err := p.ReadField1(iprot); err != nil { | |
goto ReadFieldError | |
} | |
} else { | |
if err := iprot.Skip(fieldTypeId); err != nil { | |
goto SkipFieldError | |
} | |
} | |
case 2: | |
if fieldTypeId == thrift.MAP { | |
if err := p.ReadField2(iprot); err != nil { | |
goto ReadFieldError | |
} | |
} else { | |
if err := iprot.Skip(fieldTypeId); err != nil { | |
goto SkipFieldError | |
} | |
} | |
case 3: | |
if fieldTypeId == thrift.LIST { | |
if err := p.ReadField3(iprot); err != nil { | |
goto ReadFieldError | |
} | |
} else { | |
if err := iprot.Skip(fieldTypeId); err != nil { | |
goto SkipFieldError | |
} | |
} | |
default: | |
if err := iprot.Skip(fieldTypeId); err != nil { | |
goto SkipFieldError | |
} | |
} | |
if err := iprot.ReadFieldEnd(); err != nil { | |
goto ReadFieldEndError | |
} | |
} | |
if err := iprot.ReadStructEnd(); err != nil { | |
goto ReadStructEndError | |
} | |
return nil | |
ReadStructBeginError: | |
return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) | |
ReadFieldBeginError: | |
return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) | |
ReadFieldError: | |
return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Example[fieldId]), err) | |
SkipFieldError: | |
return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) | |
ReadFieldEndError: | |
return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) | |
ReadStructEndError: | |
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) | |
} | |
func (p *Example) ReadField1(iprot thrift.TProtocol) error { | |
_, size, err := iprot.ReadListBegin() | |
if err != nil { | |
return err | |
} | |
p.Data1 = make([][]int64, 0, size) | |
for i := 0; i < size; i++ { | |
_, size, err := iprot.ReadListBegin() | |
if err != nil { | |
return err | |
} | |
_elem := make([]int64, 0, size) | |
for i := 0; i < size; i++ { | |
var _elem1 int64 | |
if v, err := iprot.ReadI64(); err != nil { | |
return err | |
} else { | |
_elem1 = v | |
} | |
_elem = append(_elem, _elem1) | |
} | |
if err := iprot.ReadListEnd(); err != nil { | |
return err | |
} | |
p.Data1 = append(p.Data1, _elem) | |
} | |
if err := iprot.ReadListEnd(); err != nil { | |
return err | |
} | |
return nil | |
} | |
func (p *Example) ReadField2(iprot thrift.TProtocol) error { | |
_, _, size, err := iprot.ReadMapBegin() | |
if err != nil { | |
return err | |
} | |
p.Data2 = make(map[int64][]int8, size) | |
for i := 0; i < size; i++ { | |
var _key int64 | |
if v, err := iprot.ReadI64(); err != nil { | |
return err | |
} else { | |
_key = v | |
} | |
_, size, err := iprot.ReadListBegin() | |
if err != nil { | |
return err | |
} | |
_val := make([]int8, 0, size) | |
for i := 0; i < size; i++ { | |
var _elem int8 | |
if v, err := iprot.ReadByte(); err != nil { | |
return err | |
} else { | |
_elem = v | |
} | |
_val = append(_val, _elem) | |
} | |
if err := iprot.ReadListEnd(); err != nil { | |
return err | |
} | |
p.Data2[_key] = _val | |
} | |
if err := iprot.ReadMapEnd(); err != nil { | |
return err | |
} | |
return nil | |
} | |
func (p *Example) ReadField3(iprot thrift.TProtocol) error { | |
_, size, err := iprot.ReadListBegin() | |
if err != nil { | |
return err | |
} | |
p.Data3 = make([]map[int64]int8, 0, size) | |
for i := 0; i < size; i++ { | |
_, _, size, err := iprot.ReadMapBegin() | |
if err != nil { | |
return err | |
} | |
_elem := make(map[int64]int8, size) | |
for i := 0; i < size; i++ { | |
var _key int64 | |
if v, err := iprot.ReadI64(); err != nil { | |
return err | |
} else { | |
_key = v | |
} | |
var _val int8 | |
if v, err := iprot.ReadByte(); err != nil { | |
return err | |
} else { | |
_val = v | |
} | |
_elem[_key] = _val | |
} | |
if err := iprot.ReadMapEnd(); err != nil { | |
return err | |
} | |
p.Data3 = append(p.Data3, _elem) | |
} | |
if err := iprot.ReadListEnd(); err != nil { | |
return err | |
} | |
return nil | |
} | |
func (p *Example) Write(oprot thrift.TProtocol) error { | |
var err error | |
var fieldId int16 | |
if err = oprot.WriteStructBegin("Example"); err != nil { | |
goto WriteStructBeginError | |
} | |
if p != nil { | |
if err = p.writeField1(oprot); err != nil { | |
fieldId = 1 | |
goto WriteFieldError | |
} | |
if err = p.writeField2(oprot); err != nil { | |
fieldId = 2 | |
goto WriteFieldError | |
} | |
if err = p.writeField3(oprot); err != nil { | |
fieldId = 3 | |
goto WriteFieldError | |
} | |
} | |
if err := oprot.WriteFieldStop(); err != nil { | |
goto WriteFieldStopError | |
} | |
if err := oprot.WriteStructEnd(); err != nil { | |
goto WriteStructEndError | |
} | |
return nil | |
WriteStructBeginError: | |
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) | |
WriteFieldError: | |
return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) | |
WriteFieldStopError: | |
return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) | |
WriteStructEndError: | |
return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) | |
} | |
func (p *Example) writeField1(oprot thrift.TProtocol) error { | |
var err error | |
var fieldId int16 | |
if err := oprot.WriteFieldBegin("data1", thrift.LIST, 1); err != nil { | |
fieldId = 1 | |
goto WriteFieldBeginError | |
} | |
if err := oprot.WriteListBegin(thrift.LIST, len(p.Data1)); err != nil { | |
return err | |
} | |
for _, v := range p.Data1 { | |
if err := oprot.WriteListBegin(thrift.I64, len(v)); err != nil { | |
return err | |
} | |
for _, v := range v { | |
if err := oprot.WriteI64(v); err != nil { | |
return err | |
} | |
} | |
if err := oprot.WriteListEnd(); err != nil { | |
return err | |
} | |
} | |
if err := oprot.WriteListEnd(); err != nil { | |
return err | |
} | |
if err := oprot.WriteFieldEnd(); err != nil { | |
fieldId = 1 | |
goto WriteFieldEndError | |
} | |
return nil | |
WriteFieldBeginError: | |
return thrift.PrependError(fmt.Sprintf("%T write field %d begin error: ", p, fieldId), err) | |
WriteFieldEndError: | |
return thrift.PrependError(fmt.Sprintf("%T write field %d end error: ", p, fieldId), err) | |
} | |
func (p *Example) writeField2(oprot thrift.TProtocol) error { | |
var err error | |
var fieldId int16 | |
if err := oprot.WriteFieldBegin("data2", thrift.MAP, 2); err != nil { | |
fieldId = 2 | |
goto WriteFieldBeginError | |
} | |
if err := oprot.WriteMapBegin(thrift.I64, thrift.LIST, len(p.Data2)); err != nil { | |
return err | |
} | |
for k, v := range p.Data2 { | |
if err := oprot.WriteI64(k); err != nil { | |
return err | |
} | |
if err := oprot.WriteListBegin(thrift.BYTE, len(v)); err != nil { | |
return err | |
} | |
for _, v := range v { | |
if err := oprot.WriteByte(v); err != nil { | |
return err | |
} | |
} | |
if err := oprot.WriteListEnd(); err != nil { | |
return err | |
} | |
} | |
if err := oprot.WriteMapEnd(); err != nil { | |
return err | |
} | |
if err := oprot.WriteFieldEnd(); err != nil { | |
fieldId = 2 | |
goto WriteFieldEndError | |
} | |
return nil | |
WriteFieldBeginError: | |
return thrift.PrependError(fmt.Sprintf("%T write field %d begin error: ", p, fieldId), err) | |
WriteFieldEndError: | |
return thrift.PrependError(fmt.Sprintf("%T write field %d end error: ", p, fieldId), err) | |
} | |
func (p *Example) writeField3(oprot thrift.TProtocol) error { | |
var err error | |
var fieldId int16 | |
if err := oprot.WriteFieldBegin("data3", thrift.LIST, 3); err != nil { | |
fieldId = 3 | |
goto WriteFieldBeginError | |
} | |
if err := oprot.WriteListBegin(thrift.MAP, len(p.Data3)); err != nil { | |
return err | |
} | |
for _, v := range p.Data3 { | |
if err := oprot.WriteMapBegin(thrift.I64, thrift.BYTE, len(v)); err != nil { | |
return err | |
} | |
for k, v := range v { | |
if err := oprot.WriteI64(k); err != nil { | |
return err | |
} | |
if err := oprot.WriteByte(v); err != nil { | |
return err | |
} | |
} | |
if err := oprot.WriteMapEnd(); err != nil { | |
return err | |
} | |
} | |
if err := oprot.WriteListEnd(); err != nil { | |
return err | |
} | |
if err := oprot.WriteFieldEnd(); err != nil { | |
fieldId = 3 | |
goto WriteFieldEndError | |
} | |
return nil | |
WriteFieldBeginError: | |
return thrift.PrependError(fmt.Sprintf("%T write field %d begin error: ", p, fieldId), err) | |
WriteFieldEndError: | |
return thrift.PrependError(fmt.Sprintf("%T write field %d end error: ", p, fieldId), err) | |
} | |
func (p *Example) String() string { | |
if p == nil { | |
return "<nil>" | |
} | |
return fmt.Sprintf("Example(%+v)", *p) | |
} | |
type Serialize interface { | |
Method(ctx context.Context, req *Example) (r *Example, err error) | |
} | |
type SerializeClient struct { | |
c thrift.TClient | |
} | |
func NewSerializeClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *SerializeClient { | |
return &SerializeClient{ | |
c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), | |
} | |
} | |
func NewSerializeClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *SerializeClient { | |
return &SerializeClient{ | |
c: thrift.NewTStandardClient(iprot, oprot), | |
} | |
} | |
func NewSerializeClient(c thrift.TClient) *SerializeClient { | |
return &SerializeClient{ | |
c: c, | |
} | |
} | |
func (p *SerializeClient) Client_() thrift.TClient { | |
return p.c | |
} | |
func (p *SerializeClient) Method(ctx context.Context, req *Example) (r *Example, err error) { | |
var _args SerializeMethodArgs | |
_args.Req = req | |
var _result SerializeMethodResult | |
if err = p.Client_().Call(ctx, "Method", &_args, &_result); err != nil { | |
return | |
} | |
return _result.GetSuccess(), nil | |
} | |
type SerializeProcessor struct { | |
processorMap map[string]thrift.TProcessorFunction | |
handler Serialize | |
} | |
func (p *SerializeProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { | |
p.processorMap[key] = processor | |
} | |
func (p *SerializeProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { | |
processor, ok = p.processorMap[key] | |
return processor, ok | |
} | |
func (p *SerializeProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { | |
return p.processorMap | |
} | |
func NewSerializeProcessor(handler Serialize) *SerializeProcessor { | |
self := &SerializeProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} | |
self.AddToProcessorMap("Method", &serializeProcessorMethod{handler: handler}) | |
return self | |
} | |
func (p *SerializeProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { | |
name, _, seqId, err := iprot.ReadMessageBegin() | |
if err != nil { | |
return false, err | |
} | |
if processor, ok := p.GetProcessorFunction(name); ok { | |
return processor.Process(ctx, seqId, iprot, oprot) | |
} | |
iprot.Skip(thrift.STRUCT) | |
iprot.ReadMessageEnd() | |
x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) | |
oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) | |
x.Write(oprot) | |
oprot.WriteMessageEnd() | |
oprot.Flush(ctx) | |
return false, x | |
} | |
type serializeProcessorMethod struct { | |
handler Serialize | |
} | |
func (p *serializeProcessorMethod) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { | |
args := SerializeMethodArgs{} | |
if err = args.Read(iprot); err != nil { | |
iprot.ReadMessageEnd() | |
x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) | |
oprot.WriteMessageBegin("Method", thrift.EXCEPTION, seqId) | |
x.Write(oprot) | |
oprot.WriteMessageEnd() | |
oprot.Flush(ctx) | |
return false, err | |
} | |
iprot.ReadMessageEnd() | |
var err2 error | |
result := SerializeMethodResult{} | |
var retval *Example | |
if retval, err2 = p.handler.Method(ctx, args.Req); err2 != nil { | |
x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing Method: "+err2.Error()) | |
oprot.WriteMessageBegin("Method", thrift.EXCEPTION, seqId) | |
x.Write(oprot) | |
oprot.WriteMessageEnd() | |
oprot.Flush(ctx) | |
return true, err2 | |
} else { | |
result.Success = retval | |
} | |
if err2 = oprot.WriteMessageBegin("Method", thrift.REPLY, seqId); err2 != nil { | |
err = err2 | |
} | |
if err2 = result.Write(oprot); err == nil && err2 != nil { | |
err = err2 | |
} | |
if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { | |
err = err2 | |
} | |
if err2 = oprot.Flush(ctx); err == nil && err2 != nil { | |
err = err2 | |
} | |
if err != nil { | |
return | |
} | |
return true, err | |
} | |
type SerializeMethodArgs struct { | |
Req *Example `thrift:"req,1" json:"req"` | |
} | |
func NewSerializeMethodArgs() *SerializeMethodArgs { | |
return &SerializeMethodArgs{} | |
} | |
var SerializeMethodArgs_Req_DEFAULT *Example | |
func (p *SerializeMethodArgs) GetReq() *Example { | |
if !p.IsSetReq() { | |
return SerializeMethodArgs_Req_DEFAULT | |
} | |
return p.Req | |
} | |
func (p *SerializeMethodArgs) SetReq(val *Example) { | |
p.Req = val | |
} | |
var fieldIDToName_SerializeMethodArgs = map[int16]string{ | |
1: "req", | |
} | |
func (p *SerializeMethodArgs) IsSetReq() bool { | |
return p.Req != nil | |
} | |
func (p *SerializeMethodArgs) Read(iprot thrift.TProtocol) error { | |
var err error | |
var fieldTypeId thrift.TType | |
var fieldId int16 | |
if _, err = iprot.ReadStructBegin(); err != nil { | |
goto ReadStructBeginError | |
} | |
for { | |
_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() | |
if err != nil { | |
goto ReadFieldBeginError | |
} | |
if fieldTypeId == thrift.STOP { | |
break | |
} | |
switch fieldId { | |
case 1: | |
if fieldTypeId == thrift.STRUCT { | |
if err := p.ReadField1(iprot); err != nil { | |
goto ReadFieldError | |
} | |
} else { | |
if err := iprot.Skip(fieldTypeId); err != nil { | |
goto SkipFieldError | |
} | |
} | |
default: | |
if err := iprot.Skip(fieldTypeId); err != nil { | |
goto SkipFieldError | |
} | |
} | |
if err := iprot.ReadFieldEnd(); err != nil { | |
goto ReadFieldEndError | |
} | |
} | |
if err := iprot.ReadStructEnd(); err != nil { | |
goto ReadStructEndError | |
} | |
return nil | |
ReadStructBeginError: | |
return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) | |
ReadFieldBeginError: | |
return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) | |
ReadFieldError: | |
return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_SerializeMethodArgs[fieldId]), err) | |
SkipFieldError: | |
return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) | |
ReadFieldEndError: | |
return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) | |
ReadStructEndError: | |
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) | |
} | |
func (p *SerializeMethodArgs) ReadField1(iprot thrift.TProtocol) error { | |
p.Req = NewExample() | |
if err := p.Req.Read(iprot); err != nil { | |
return err | |
} | |
return nil | |
} | |
func (p *SerializeMethodArgs) Write(oprot thrift.TProtocol) error { | |
var err error | |
var fieldId int16 | |
if err = oprot.WriteStructBegin("method_args"); err != nil { | |
goto WriteStructBeginError | |
} | |
if p != nil { | |
if err = p.writeField1(oprot); err != nil { | |
fieldId = 1 | |
goto WriteFieldError | |
} | |
} | |
if err := oprot.WriteFieldStop(); err != nil { | |
goto WriteFieldStopError | |
} | |
if err := oprot.WriteStructEnd(); err != nil { | |
goto WriteStructEndError | |
} | |
return nil | |
WriteStructBeginError: | |
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) | |
WriteFieldError: | |
return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) | |
WriteFieldStopError: | |
return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) | |
WriteStructEndError: | |
return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) | |
} | |
func (p *SerializeMethodArgs) writeField1(oprot thrift.TProtocol) error { | |
var err error | |
var fieldId int16 | |
if err := oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil { | |
fieldId = 1 | |
goto WriteFieldBeginError | |
} | |
if err := p.Req.Write(oprot); err != nil { | |
return err | |
} | |
if err := oprot.WriteFieldEnd(); err != nil { | |
fieldId = 1 | |
goto WriteFieldEndError | |
} | |
return nil | |
WriteFieldBeginError: | |
return thrift.PrependError(fmt.Sprintf("%T write field %d begin error: ", p, fieldId), err) | |
WriteFieldEndError: | |
return thrift.PrependError(fmt.Sprintf("%T write field %d end error: ", p, fieldId), err) | |
} | |
func (p *SerializeMethodArgs) String() string { | |
if p == nil { | |
return "<nil>" | |
} | |
return fmt.Sprintf("SerializeMethodArgs(%+v)", *p) | |
} | |
type SerializeMethodResult struct { | |
Success *Example `thrift:"success,0" json:"success,omitempty"` | |
} | |
func NewSerializeMethodResult() *SerializeMethodResult { | |
return &SerializeMethodResult{} | |
} | |
var SerializeMethodResult_Success_DEFAULT *Example | |
func (p *SerializeMethodResult) GetSuccess() *Example { | |
if !p.IsSetSuccess() { | |
return SerializeMethodResult_Success_DEFAULT | |
} | |
return p.Success | |
} | |
func (p *SerializeMethodResult) SetSuccess(x interface{}) { | |
p.Success = x.(*Example) | |
} | |
var fieldIDToName_SerializeMethodResult = map[int16]string{ | |
0: "success", | |
} | |
func (p *SerializeMethodResult) IsSetSuccess() bool { | |
return p.Success != nil | |
} | |
func (p *SerializeMethodResult) Read(iprot thrift.TProtocol) error { | |
var err error | |
var fieldTypeId thrift.TType | |
var fieldId int16 | |
if _, err = iprot.ReadStructBegin(); err != nil { | |
goto ReadStructBeginError | |
} | |
for { | |
_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin() | |
if err != nil { | |
goto ReadFieldBeginError | |
} | |
if fieldTypeId == thrift.STOP { | |
break | |
} | |
switch fieldId { | |
case 0: | |
if fieldTypeId == thrift.STRUCT { | |
if err := p.ReadField0(iprot); err != nil { | |
goto ReadFieldError | |
} | |
} else { | |
if err := iprot.Skip(fieldTypeId); err != nil { | |
goto SkipFieldError | |
} | |
} | |
default: | |
if err := iprot.Skip(fieldTypeId); err != nil { | |
goto SkipFieldError | |
} | |
} | |
if err := iprot.ReadFieldEnd(); err != nil { | |
goto ReadFieldEndError | |
} | |
} | |
if err := iprot.ReadStructEnd(); err != nil { | |
goto ReadStructEndError | |
} | |
return nil | |
ReadStructBeginError: | |
return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err) | |
ReadFieldBeginError: | |
return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err) | |
ReadFieldError: | |
return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_SerializeMethodResult[fieldId]), err) | |
SkipFieldError: | |
return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err) | |
ReadFieldEndError: | |
return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err) | |
ReadStructEndError: | |
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) | |
} | |
func (p *SerializeMethodResult) ReadField0(iprot thrift.TProtocol) error { | |
p.Success = NewExample() | |
if err := p.Success.Read(iprot); err != nil { | |
return err | |
} | |
return nil | |
} | |
func (p *SerializeMethodResult) Write(oprot thrift.TProtocol) error { | |
var err error | |
var fieldId int16 | |
if err = oprot.WriteStructBegin("method_result"); err != nil { | |
goto WriteStructBeginError | |
} | |
if p != nil { | |
if err = p.writeField0(oprot); err != nil { | |
fieldId = 0 | |
goto WriteFieldError | |
} | |
} | |
if err := oprot.WriteFieldStop(); err != nil { | |
goto WriteFieldStopError | |
} | |
if err := oprot.WriteStructEnd(); err != nil { | |
goto WriteStructEndError | |
} | |
return nil | |
WriteStructBeginError: | |
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) | |
WriteFieldError: | |
return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err) | |
WriteFieldStopError: | |
return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err) | |
WriteStructEndError: | |
return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err) | |
} | |
func (p *SerializeMethodResult) writeField0(oprot thrift.TProtocol) error { | |
var err error | |
var fieldId int16 | |
if p.IsSetSuccess() { | |
if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { | |
fieldId = 0 | |
goto WriteFieldBeginError | |
} | |
if err := p.Success.Write(oprot); err != nil { | |
return err | |
} | |
if err := oprot.WriteFieldEnd(); err != nil { | |
fieldId = 0 | |
goto WriteFieldEndError | |
} | |
} | |
return nil | |
WriteFieldBeginError: | |
return thrift.PrependError(fmt.Sprintf("%T write field %d begin error: ", p, fieldId), err) | |
WriteFieldEndError: | |
return thrift.PrependError(fmt.Sprintf("%T write field %d end error: ", p, fieldId), err) | |
} | |
func (p *SerializeMethodResult) String() string { | |
if p == nil { | |
return "<nil>" | |
} | |
return fmt.Sprintf("SerializeMethodResult(%+v)", *p) | |
} | |
func (p *SerializeMethodArgs) GetFirstArgument() interface{} { | |
return p.Req | |
} | |
func (p *SerializeMethodResult) GetResult() interface{} { | |
return p.Success | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment