github.com/cloudwego/dynamicgo@v0.2.6-0.20240519101509-707f41b6b834/testdata/kitex_gen/null/null.go (about)

     1  // Code generated by thriftgo (0.1.3). DO NOT EDIT.
     2  
     3  package null
     4  
     5  import (
     6  	"context"
     7  	"fmt"
     8  	"github.com/apache/thrift/lib/go/thrift"
     9  )
    10  
    11  type NullStruct struct {
    12  	Null1 int64            `thrift:"Null1,1" json:"Null1"`
    13  	Null2 *int64           `thrift:"Null2,2" json:"Null2,omitempty"`
    14  	Null3 int64            `thrift:"Null3,3,required" json:"Null3"`
    15  	Null4 []int64          `thrift:"Null4,4" json:"Null4"`
    16  	Null5 map[string]int64 `thrift:"Null5,5" json:"Null5"`
    17  	Null6 map[int64]int64  `thrift:"Null6,6" json:"Null6"`
    18  }
    19  
    20  func NewNullStruct() *NullStruct {
    21  	return &NullStruct{}
    22  }
    23  
    24  func (p *NullStruct) GetNull1() (v int64) {
    25  	return p.Null1
    26  }
    27  
    28  var NullStruct_Null2_DEFAULT int64
    29  
    30  func (p *NullStruct) GetNull2() (v int64) {
    31  	if !p.IsSetNull2() {
    32  		return NullStruct_Null2_DEFAULT
    33  	}
    34  	return *p.Null2
    35  }
    36  
    37  func (p *NullStruct) GetNull3() (v int64) {
    38  	return p.Null3
    39  }
    40  
    41  func (p *NullStruct) GetNull4() (v []int64) {
    42  	return p.Null4
    43  }
    44  
    45  func (p *NullStruct) GetNull5() (v map[string]int64) {
    46  	return p.Null5
    47  }
    48  
    49  func (p *NullStruct) GetNull6() (v map[int64]int64) {
    50  	return p.Null6
    51  }
    52  func (p *NullStruct) SetNull1(val int64) {
    53  	p.Null1 = val
    54  }
    55  func (p *NullStruct) SetNull2(val *int64) {
    56  	p.Null2 = val
    57  }
    58  func (p *NullStruct) SetNull3(val int64) {
    59  	p.Null3 = val
    60  }
    61  func (p *NullStruct) SetNull4(val []int64) {
    62  	p.Null4 = val
    63  }
    64  func (p *NullStruct) SetNull5(val map[string]int64) {
    65  	p.Null5 = val
    66  }
    67  func (p *NullStruct) SetNull6(val map[int64]int64) {
    68  	p.Null6 = val
    69  }
    70  
    71  var fieldIDToName_NullStruct = map[int16]string{
    72  	1: "Null1",
    73  	2: "Null2",
    74  	3: "Null3",
    75  	4: "Null4",
    76  	5: "Null5",
    77  	6: "Null6",
    78  }
    79  
    80  func (p *NullStruct) IsSetNull2() bool {
    81  	return p.Null2 != nil
    82  }
    83  
    84  func (p *NullStruct) Read(iprot thrift.TProtocol) (err error) {
    85  
    86  	var fieldTypeId thrift.TType
    87  	var fieldId int16
    88  	var issetNull3 bool = false
    89  
    90  	if _, err = iprot.ReadStructBegin(); err != nil {
    91  		goto ReadStructBeginError
    92  	}
    93  
    94  	for {
    95  		_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
    96  		if err != nil {
    97  			goto ReadFieldBeginError
    98  		}
    99  		if fieldTypeId == thrift.STOP {
   100  			break
   101  		}
   102  
   103  		switch fieldId {
   104  		case 1:
   105  			if fieldTypeId == thrift.I64 {
   106  				if err = p.ReadField1(iprot); err != nil {
   107  					goto ReadFieldError
   108  				}
   109  			} else {
   110  				if err = iprot.Skip(fieldTypeId); err != nil {
   111  					goto SkipFieldError
   112  				}
   113  			}
   114  		case 2:
   115  			if fieldTypeId == thrift.I64 {
   116  				if err = p.ReadField2(iprot); err != nil {
   117  					goto ReadFieldError
   118  				}
   119  			} else {
   120  				if err = iprot.Skip(fieldTypeId); err != nil {
   121  					goto SkipFieldError
   122  				}
   123  			}
   124  		case 3:
   125  			if fieldTypeId == thrift.I64 {
   126  				if err = p.ReadField3(iprot); err != nil {
   127  					goto ReadFieldError
   128  				}
   129  				issetNull3 = true
   130  			} else {
   131  				if err = iprot.Skip(fieldTypeId); err != nil {
   132  					goto SkipFieldError
   133  				}
   134  			}
   135  		case 4:
   136  			if fieldTypeId == thrift.LIST {
   137  				if err = p.ReadField4(iprot); err != nil {
   138  					goto ReadFieldError
   139  				}
   140  			} else {
   141  				if err = iprot.Skip(fieldTypeId); err != nil {
   142  					goto SkipFieldError
   143  				}
   144  			}
   145  		case 5:
   146  			if fieldTypeId == thrift.MAP {
   147  				if err = p.ReadField5(iprot); err != nil {
   148  					goto ReadFieldError
   149  				}
   150  			} else {
   151  				if err = iprot.Skip(fieldTypeId); err != nil {
   152  					goto SkipFieldError
   153  				}
   154  			}
   155  		case 6:
   156  			if fieldTypeId == thrift.MAP {
   157  				if err = p.ReadField6(iprot); err != nil {
   158  					goto ReadFieldError
   159  				}
   160  			} else {
   161  				if err = iprot.Skip(fieldTypeId); err != nil {
   162  					goto SkipFieldError
   163  				}
   164  			}
   165  		default:
   166  			if err = iprot.Skip(fieldTypeId); err != nil {
   167  				goto SkipFieldError
   168  			}
   169  		}
   170  
   171  		if err = iprot.ReadFieldEnd(); err != nil {
   172  			goto ReadFieldEndError
   173  		}
   174  	}
   175  	if err = iprot.ReadStructEnd(); err != nil {
   176  		goto ReadStructEndError
   177  	}
   178  
   179  	if !issetNull3 {
   180  		fieldId = 3
   181  		goto RequiredFieldNotSetError
   182  	}
   183  	return nil
   184  ReadStructBeginError:
   185  	return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
   186  ReadFieldBeginError:
   187  	return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
   188  ReadFieldError:
   189  	return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_NullStruct[fieldId]), err)
   190  SkipFieldError:
   191  	return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
   192  
   193  ReadFieldEndError:
   194  	return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
   195  ReadStructEndError:
   196  	return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
   197  RequiredFieldNotSetError:
   198  	return thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("Required field %s is not set", fieldIDToName_NullStruct[fieldId]))
   199  }
   200  
   201  func (p *NullStruct) ReadField1(iprot thrift.TProtocol) error {
   202  	if v, err := iprot.ReadI64(); err != nil {
   203  		return err
   204  	} else {
   205  		p.Null1 = v
   206  	}
   207  	return nil
   208  }
   209  
   210  func (p *NullStruct) ReadField2(iprot thrift.TProtocol) error {
   211  	if v, err := iprot.ReadI64(); err != nil {
   212  		return err
   213  	} else {
   214  		p.Null2 = &v
   215  	}
   216  	return nil
   217  }
   218  
   219  func (p *NullStruct) ReadField3(iprot thrift.TProtocol) error {
   220  	if v, err := iprot.ReadI64(); err != nil {
   221  		return err
   222  	} else {
   223  		p.Null3 = v
   224  	}
   225  	return nil
   226  }
   227  
   228  func (p *NullStruct) ReadField4(iprot thrift.TProtocol) error {
   229  	_, size, err := iprot.ReadListBegin()
   230  	if err != nil {
   231  		return err
   232  	}
   233  	p.Null4 = make([]int64, 0, size)
   234  	for i := 0; i < size; i++ {
   235  		var _elem int64
   236  		if v, err := iprot.ReadI64(); err != nil {
   237  			return err
   238  		} else {
   239  			_elem = v
   240  		}
   241  
   242  		p.Null4 = append(p.Null4, _elem)
   243  	}
   244  	if err := iprot.ReadListEnd(); err != nil {
   245  		return err
   246  	}
   247  	return nil
   248  }
   249  
   250  func (p *NullStruct) ReadField5(iprot thrift.TProtocol) error {
   251  	_, _, size, err := iprot.ReadMapBegin()
   252  	if err != nil {
   253  		return err
   254  	}
   255  	p.Null5 = make(map[string]int64, size)
   256  	for i := 0; i < size; i++ {
   257  		var _key string
   258  		if v, err := iprot.ReadString(); err != nil {
   259  			return err
   260  		} else {
   261  			_key = v
   262  		}
   263  
   264  		var _val int64
   265  		if v, err := iprot.ReadI64(); err != nil {
   266  			return err
   267  		} else {
   268  			_val = v
   269  		}
   270  
   271  		p.Null5[_key] = _val
   272  	}
   273  	if err := iprot.ReadMapEnd(); err != nil {
   274  		return err
   275  	}
   276  	return nil
   277  }
   278  
   279  func (p *NullStruct) ReadField6(iprot thrift.TProtocol) error {
   280  	_, _, size, err := iprot.ReadMapBegin()
   281  	if err != nil {
   282  		return err
   283  	}
   284  	p.Null6 = make(map[int64]int64, size)
   285  	for i := 0; i < size; i++ {
   286  		var _key int64
   287  		if v, err := iprot.ReadI64(); err != nil {
   288  			return err
   289  		} else {
   290  			_key = v
   291  		}
   292  
   293  		var _val int64
   294  		if v, err := iprot.ReadI64(); err != nil {
   295  			return err
   296  		} else {
   297  			_val = v
   298  		}
   299  
   300  		p.Null6[_key] = _val
   301  	}
   302  	if err := iprot.ReadMapEnd(); err != nil {
   303  		return err
   304  	}
   305  	return nil
   306  }
   307  
   308  func (p *NullStruct) Write(oprot thrift.TProtocol) (err error) {
   309  	var fieldId int16
   310  	if err = oprot.WriteStructBegin("NullStruct"); err != nil {
   311  		goto WriteStructBeginError
   312  	}
   313  	if p != nil {
   314  		if err = p.writeField1(oprot); err != nil {
   315  			fieldId = 1
   316  			goto WriteFieldError
   317  		}
   318  		if err = p.writeField2(oprot); err != nil {
   319  			fieldId = 2
   320  			goto WriteFieldError
   321  		}
   322  		if err = p.writeField3(oprot); err != nil {
   323  			fieldId = 3
   324  			goto WriteFieldError
   325  		}
   326  		if err = p.writeField4(oprot); err != nil {
   327  			fieldId = 4
   328  			goto WriteFieldError
   329  		}
   330  		if err = p.writeField5(oprot); err != nil {
   331  			fieldId = 5
   332  			goto WriteFieldError
   333  		}
   334  		if err = p.writeField6(oprot); err != nil {
   335  			fieldId = 6
   336  			goto WriteFieldError
   337  		}
   338  
   339  	}
   340  	if err = oprot.WriteFieldStop(); err != nil {
   341  		goto WriteFieldStopError
   342  	}
   343  	if err = oprot.WriteStructEnd(); err != nil {
   344  		goto WriteStructEndError
   345  	}
   346  	return nil
   347  WriteStructBeginError:
   348  	return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
   349  WriteFieldError:
   350  	return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
   351  WriteFieldStopError:
   352  	return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
   353  WriteStructEndError:
   354  	return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
   355  }
   356  
   357  func (p *NullStruct) writeField1(oprot thrift.TProtocol) (err error) {
   358  	if err = oprot.WriteFieldBegin("Null1", thrift.I64, 1); err != nil {
   359  		goto WriteFieldBeginError
   360  	}
   361  	if err := oprot.WriteI64(p.Null1); err != nil {
   362  		return err
   363  	}
   364  	if err = oprot.WriteFieldEnd(); err != nil {
   365  		goto WriteFieldEndError
   366  	}
   367  	return nil
   368  WriteFieldBeginError:
   369  	return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
   370  WriteFieldEndError:
   371  	return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
   372  }
   373  
   374  func (p *NullStruct) writeField2(oprot thrift.TProtocol) (err error) {
   375  	if p.IsSetNull2() {
   376  		if err = oprot.WriteFieldBegin("Null2", thrift.I64, 2); err != nil {
   377  			goto WriteFieldBeginError
   378  		}
   379  		if err := oprot.WriteI64(*p.Null2); err != nil {
   380  			return err
   381  		}
   382  		if err = oprot.WriteFieldEnd(); err != nil {
   383  			goto WriteFieldEndError
   384  		}
   385  	}
   386  	return nil
   387  WriteFieldBeginError:
   388  	return thrift.PrependError(fmt.Sprintf("%T write field 2 begin error: ", p), err)
   389  WriteFieldEndError:
   390  	return thrift.PrependError(fmt.Sprintf("%T write field 2 end error: ", p), err)
   391  }
   392  
   393  func (p *NullStruct) writeField3(oprot thrift.TProtocol) (err error) {
   394  	if err = oprot.WriteFieldBegin("Null3", thrift.I64, 3); err != nil {
   395  		goto WriteFieldBeginError
   396  	}
   397  	if err := oprot.WriteI64(p.Null3); err != nil {
   398  		return err
   399  	}
   400  	if err = oprot.WriteFieldEnd(); err != nil {
   401  		goto WriteFieldEndError
   402  	}
   403  	return nil
   404  WriteFieldBeginError:
   405  	return thrift.PrependError(fmt.Sprintf("%T write field 3 begin error: ", p), err)
   406  WriteFieldEndError:
   407  	return thrift.PrependError(fmt.Sprintf("%T write field 3 end error: ", p), err)
   408  }
   409  
   410  func (p *NullStruct) writeField4(oprot thrift.TProtocol) (err error) {
   411  	if err = oprot.WriteFieldBegin("Null4", thrift.LIST, 4); err != nil {
   412  		goto WriteFieldBeginError
   413  	}
   414  	if err := oprot.WriteListBegin(thrift.I64, len(p.Null4)); err != nil {
   415  		return err
   416  	}
   417  	for _, v := range p.Null4 {
   418  		if err := oprot.WriteI64(v); err != nil {
   419  			return err
   420  		}
   421  	}
   422  	if err := oprot.WriteListEnd(); err != nil {
   423  		return err
   424  	}
   425  	if err = oprot.WriteFieldEnd(); err != nil {
   426  		goto WriteFieldEndError
   427  	}
   428  	return nil
   429  WriteFieldBeginError:
   430  	return thrift.PrependError(fmt.Sprintf("%T write field 4 begin error: ", p), err)
   431  WriteFieldEndError:
   432  	return thrift.PrependError(fmt.Sprintf("%T write field 4 end error: ", p), err)
   433  }
   434  
   435  func (p *NullStruct) writeField5(oprot thrift.TProtocol) (err error) {
   436  	if err = oprot.WriteFieldBegin("Null5", thrift.MAP, 5); err != nil {
   437  		goto WriteFieldBeginError
   438  	}
   439  	if err := oprot.WriteMapBegin(thrift.STRING, thrift.I64, len(p.Null5)); err != nil {
   440  		return err
   441  	}
   442  	for k, v := range p.Null5 {
   443  
   444  		if err := oprot.WriteString(k); err != nil {
   445  			return err
   446  		}
   447  
   448  		if err := oprot.WriteI64(v); err != nil {
   449  			return err
   450  		}
   451  	}
   452  	if err := oprot.WriteMapEnd(); err != nil {
   453  		return err
   454  	}
   455  	if err = oprot.WriteFieldEnd(); err != nil {
   456  		goto WriteFieldEndError
   457  	}
   458  	return nil
   459  WriteFieldBeginError:
   460  	return thrift.PrependError(fmt.Sprintf("%T write field 5 begin error: ", p), err)
   461  WriteFieldEndError:
   462  	return thrift.PrependError(fmt.Sprintf("%T write field 5 end error: ", p), err)
   463  }
   464  
   465  func (p *NullStruct) writeField6(oprot thrift.TProtocol) (err error) {
   466  	if err = oprot.WriteFieldBegin("Null6", thrift.MAP, 6); err != nil {
   467  		goto WriteFieldBeginError
   468  	}
   469  	if err := oprot.WriteMapBegin(thrift.I64, thrift.I64, len(p.Null6)); err != nil {
   470  		return err
   471  	}
   472  	for k, v := range p.Null6 {
   473  
   474  		if err := oprot.WriteI64(k); err != nil {
   475  			return err
   476  		}
   477  
   478  		if err := oprot.WriteI64(v); err != nil {
   479  			return err
   480  		}
   481  	}
   482  	if err := oprot.WriteMapEnd(); err != nil {
   483  		return err
   484  	}
   485  	if err = oprot.WriteFieldEnd(); err != nil {
   486  		goto WriteFieldEndError
   487  	}
   488  	return nil
   489  WriteFieldBeginError:
   490  	return thrift.PrependError(fmt.Sprintf("%T write field 6 begin error: ", p), err)
   491  WriteFieldEndError:
   492  	return thrift.PrependError(fmt.Sprintf("%T write field 6 end error: ", p), err)
   493  }
   494  
   495  func (p *NullStruct) String() string {
   496  	if p == nil {
   497  		return "<nil>"
   498  	}
   499  	return fmt.Sprintf("NullStruct(%+v)", *p)
   500  }
   501  
   502  func (p *NullStruct) DeepEqual(ano *NullStruct) bool {
   503  	if p == ano {
   504  		return true
   505  	} else if p == nil || ano == nil {
   506  		return false
   507  	}
   508  	if !p.Field1DeepEqual(ano.Null1) {
   509  		return false
   510  	}
   511  	if !p.Field2DeepEqual(ano.Null2) {
   512  		return false
   513  	}
   514  	if !p.Field3DeepEqual(ano.Null3) {
   515  		return false
   516  	}
   517  	if !p.Field4DeepEqual(ano.Null4) {
   518  		return false
   519  	}
   520  	if !p.Field5DeepEqual(ano.Null5) {
   521  		return false
   522  	}
   523  	if !p.Field6DeepEqual(ano.Null6) {
   524  		return false
   525  	}
   526  	return true
   527  }
   528  
   529  func (p *NullStruct) Field1DeepEqual(src int64) bool {
   530  
   531  	if p.Null1 != src {
   532  		return false
   533  	}
   534  	return true
   535  }
   536  func (p *NullStruct) Field2DeepEqual(src *int64) bool {
   537  
   538  	if p.Null2 == src {
   539  		return true
   540  	} else if p.Null2 == nil || src == nil {
   541  		return false
   542  	}
   543  	if *p.Null2 != *src {
   544  		return false
   545  	}
   546  	return true
   547  }
   548  func (p *NullStruct) Field3DeepEqual(src int64) bool {
   549  
   550  	if p.Null3 != src {
   551  		return false
   552  	}
   553  	return true
   554  }
   555  func (p *NullStruct) Field4DeepEqual(src []int64) bool {
   556  
   557  	if len(p.Null4) != len(src) {
   558  		return false
   559  	}
   560  	for i, v := range p.Null4 {
   561  		_src := src[i]
   562  		if v != _src {
   563  			return false
   564  		}
   565  	}
   566  	return true
   567  }
   568  func (p *NullStruct) Field5DeepEqual(src map[string]int64) bool {
   569  
   570  	if len(p.Null5) != len(src) {
   571  		return false
   572  	}
   573  	for k, v := range p.Null5 {
   574  		_src := src[k]
   575  		if v != _src {
   576  			return false
   577  		}
   578  	}
   579  	return true
   580  }
   581  func (p *NullStruct) Field6DeepEqual(src map[int64]int64) bool {
   582  
   583  	if len(p.Null6) != len(src) {
   584  		return false
   585  	}
   586  	for k, v := range p.Null6 {
   587  		_src := src[k]
   588  		if v != _src {
   589  			return false
   590  		}
   591  	}
   592  	return true
   593  }
   594  
   595  type NullService interface {
   596  	NullTest(ctx context.Context, req *NullStruct) (r *NullStruct, err error)
   597  }
   598  
   599  type NullServiceClient struct {
   600  	c thrift.TClient
   601  }
   602  
   603  func NewNullServiceClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *NullServiceClient {
   604  	return &NullServiceClient{
   605  		c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)),
   606  	}
   607  }
   608  
   609  func NewNullServiceClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *NullServiceClient {
   610  	return &NullServiceClient{
   611  		c: thrift.NewTStandardClient(iprot, oprot),
   612  	}
   613  }
   614  
   615  func NewNullServiceClient(c thrift.TClient) *NullServiceClient {
   616  	return &NullServiceClient{
   617  		c: c,
   618  	}
   619  }
   620  
   621  func (p *NullServiceClient) Client_() thrift.TClient {
   622  	return p.c
   623  }
   624  
   625  func (p *NullServiceClient) NullTest(ctx context.Context, req *NullStruct) (r *NullStruct, err error) {
   626  	var _args NullServiceNullTestArgs
   627  	_args.Req = req
   628  	var _result NullServiceNullTestResult
   629  	if err = p.Client_().Call(ctx, "NullTest", &_args, &_result); err != nil {
   630  		return
   631  	}
   632  	return _result.GetSuccess(), nil
   633  }
   634  
   635  type NullServiceProcessor struct {
   636  	processorMap map[string]thrift.TProcessorFunction
   637  	handler      NullService
   638  }
   639  
   640  func (p *NullServiceProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) {
   641  	p.processorMap[key] = processor
   642  }
   643  
   644  func (p *NullServiceProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) {
   645  	processor, ok = p.processorMap[key]
   646  	return processor, ok
   647  }
   648  
   649  func (p *NullServiceProcessor) ProcessorMap() map[string]thrift.TProcessorFunction {
   650  	return p.processorMap
   651  }
   652  
   653  func NewNullServiceProcessor(handler NullService) *NullServiceProcessor {
   654  	self := &NullServiceProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)}
   655  	self.AddToProcessorMap("NullTest", &nullServiceProcessorNullTest{handler: handler})
   656  	return self
   657  }
   658  func (p *NullServiceProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
   659  	name, _, seqId, err := iprot.ReadMessageBegin()
   660  	if err != nil {
   661  		return false, err
   662  	}
   663  	if processor, ok := p.GetProcessorFunction(name); ok {
   664  		return processor.Process(ctx, seqId, iprot, oprot)
   665  	}
   666  	iprot.Skip(thrift.STRUCT)
   667  	iprot.ReadMessageEnd()
   668  	x := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name)
   669  	oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId)
   670  	x.Write(oprot)
   671  	oprot.WriteMessageEnd()
   672  	oprot.Flush(ctx)
   673  	return false, x
   674  }
   675  
   676  type nullServiceProcessorNullTest struct {
   677  	handler NullService
   678  }
   679  
   680  func (p *nullServiceProcessorNullTest) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) {
   681  	args := NullServiceNullTestArgs{}
   682  	if err = args.Read(iprot); err != nil {
   683  		iprot.ReadMessageEnd()
   684  		x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error())
   685  		oprot.WriteMessageBegin("NullTest", thrift.EXCEPTION, seqId)
   686  		x.Write(oprot)
   687  		oprot.WriteMessageEnd()
   688  		oprot.Flush(ctx)
   689  		return false, err
   690  	}
   691  
   692  	iprot.ReadMessageEnd()
   693  	var err2 error
   694  	result := NullServiceNullTestResult{}
   695  	var retval *NullStruct
   696  	if retval, err2 = p.handler.NullTest(ctx, args.Req); err2 != nil {
   697  		x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing NullTest: "+err2.Error())
   698  		oprot.WriteMessageBegin("NullTest", thrift.EXCEPTION, seqId)
   699  		x.Write(oprot)
   700  		oprot.WriteMessageEnd()
   701  		oprot.Flush(ctx)
   702  		return true, err2
   703  	} else {
   704  		result.Success = retval
   705  	}
   706  	if err2 = oprot.WriteMessageBegin("NullTest", thrift.REPLY, seqId); err2 != nil {
   707  		err = err2
   708  	}
   709  	if err2 = result.Write(oprot); err == nil && err2 != nil {
   710  		err = err2
   711  	}
   712  	if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil {
   713  		err = err2
   714  	}
   715  	if err2 = oprot.Flush(ctx); err == nil && err2 != nil {
   716  		err = err2
   717  	}
   718  	if err != nil {
   719  		return
   720  	}
   721  	return true, err
   722  }
   723  
   724  type NullServiceNullTestArgs struct {
   725  	Req *NullStruct `thrift:"req,1" json:"req"`
   726  }
   727  
   728  func NewNullServiceNullTestArgs() *NullServiceNullTestArgs {
   729  	return &NullServiceNullTestArgs{}
   730  }
   731  
   732  var NullServiceNullTestArgs_Req_DEFAULT *NullStruct
   733  
   734  func (p *NullServiceNullTestArgs) GetReq() (v *NullStruct) {
   735  	if !p.IsSetReq() {
   736  		return NullServiceNullTestArgs_Req_DEFAULT
   737  	}
   738  	return p.Req
   739  }
   740  func (p *NullServiceNullTestArgs) SetReq(val *NullStruct) {
   741  	p.Req = val
   742  }
   743  
   744  var fieldIDToName_NullServiceNullTestArgs = map[int16]string{
   745  	1: "req",
   746  }
   747  
   748  func (p *NullServiceNullTestArgs) IsSetReq() bool {
   749  	return p.Req != nil
   750  }
   751  
   752  func (p *NullServiceNullTestArgs) Read(iprot thrift.TProtocol) (err error) {
   753  
   754  	var fieldTypeId thrift.TType
   755  	var fieldId int16
   756  
   757  	if _, err = iprot.ReadStructBegin(); err != nil {
   758  		goto ReadStructBeginError
   759  	}
   760  
   761  	for {
   762  		_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
   763  		if err != nil {
   764  			goto ReadFieldBeginError
   765  		}
   766  		if fieldTypeId == thrift.STOP {
   767  			break
   768  		}
   769  
   770  		switch fieldId {
   771  		case 1:
   772  			if fieldTypeId == thrift.STRUCT {
   773  				if err = p.ReadField1(iprot); err != nil {
   774  					goto ReadFieldError
   775  				}
   776  			} else {
   777  				if err = iprot.Skip(fieldTypeId); err != nil {
   778  					goto SkipFieldError
   779  				}
   780  			}
   781  		default:
   782  			if err = iprot.Skip(fieldTypeId); err != nil {
   783  				goto SkipFieldError
   784  			}
   785  		}
   786  
   787  		if err = iprot.ReadFieldEnd(); err != nil {
   788  			goto ReadFieldEndError
   789  		}
   790  	}
   791  	if err = iprot.ReadStructEnd(); err != nil {
   792  		goto ReadStructEndError
   793  	}
   794  
   795  	return nil
   796  ReadStructBeginError:
   797  	return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
   798  ReadFieldBeginError:
   799  	return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
   800  ReadFieldError:
   801  	return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_NullServiceNullTestArgs[fieldId]), err)
   802  SkipFieldError:
   803  	return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
   804  
   805  ReadFieldEndError:
   806  	return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
   807  ReadStructEndError:
   808  	return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
   809  }
   810  
   811  func (p *NullServiceNullTestArgs) ReadField1(iprot thrift.TProtocol) error {
   812  	p.Req = NewNullStruct()
   813  	if err := p.Req.Read(iprot); err != nil {
   814  		return err
   815  	}
   816  	return nil
   817  }
   818  
   819  func (p *NullServiceNullTestArgs) Write(oprot thrift.TProtocol) (err error) {
   820  	var fieldId int16
   821  	if err = oprot.WriteStructBegin("NullTest_args"); err != nil {
   822  		goto WriteStructBeginError
   823  	}
   824  	if p != nil {
   825  		if err = p.writeField1(oprot); err != nil {
   826  			fieldId = 1
   827  			goto WriteFieldError
   828  		}
   829  
   830  	}
   831  	if err = oprot.WriteFieldStop(); err != nil {
   832  		goto WriteFieldStopError
   833  	}
   834  	if err = oprot.WriteStructEnd(); err != nil {
   835  		goto WriteStructEndError
   836  	}
   837  	return nil
   838  WriteStructBeginError:
   839  	return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
   840  WriteFieldError:
   841  	return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
   842  WriteFieldStopError:
   843  	return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
   844  WriteStructEndError:
   845  	return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
   846  }
   847  
   848  func (p *NullServiceNullTestArgs) writeField1(oprot thrift.TProtocol) (err error) {
   849  	if err = oprot.WriteFieldBegin("req", thrift.STRUCT, 1); err != nil {
   850  		goto WriteFieldBeginError
   851  	}
   852  	if err := p.Req.Write(oprot); err != nil {
   853  		return err
   854  	}
   855  	if err = oprot.WriteFieldEnd(); err != nil {
   856  		goto WriteFieldEndError
   857  	}
   858  	return nil
   859  WriteFieldBeginError:
   860  	return thrift.PrependError(fmt.Sprintf("%T write field 1 begin error: ", p), err)
   861  WriteFieldEndError:
   862  	return thrift.PrependError(fmt.Sprintf("%T write field 1 end error: ", p), err)
   863  }
   864  
   865  func (p *NullServiceNullTestArgs) String() string {
   866  	if p == nil {
   867  		return "<nil>"
   868  	}
   869  	return fmt.Sprintf("NullServiceNullTestArgs(%+v)", *p)
   870  }
   871  
   872  func (p *NullServiceNullTestArgs) DeepEqual(ano *NullServiceNullTestArgs) bool {
   873  	if p == ano {
   874  		return true
   875  	} else if p == nil || ano == nil {
   876  		return false
   877  	}
   878  	if !p.Field1DeepEqual(ano.Req) {
   879  		return false
   880  	}
   881  	return true
   882  }
   883  
   884  func (p *NullServiceNullTestArgs) Field1DeepEqual(src *NullStruct) bool {
   885  
   886  	if !p.Req.DeepEqual(src) {
   887  		return false
   888  	}
   889  	return true
   890  }
   891  
   892  type NullServiceNullTestResult struct {
   893  	Success *NullStruct `thrift:"success,0" json:"success,omitempty"`
   894  }
   895  
   896  func NewNullServiceNullTestResult() *NullServiceNullTestResult {
   897  	return &NullServiceNullTestResult{}
   898  }
   899  
   900  var NullServiceNullTestResult_Success_DEFAULT *NullStruct
   901  
   902  func (p *NullServiceNullTestResult) GetSuccess() (v *NullStruct) {
   903  	if !p.IsSetSuccess() {
   904  		return NullServiceNullTestResult_Success_DEFAULT
   905  	}
   906  	return p.Success
   907  }
   908  func (p *NullServiceNullTestResult) SetSuccess(x interface{}) {
   909  	p.Success = x.(*NullStruct)
   910  }
   911  
   912  var fieldIDToName_NullServiceNullTestResult = map[int16]string{
   913  	0: "success",
   914  }
   915  
   916  func (p *NullServiceNullTestResult) IsSetSuccess() bool {
   917  	return p.Success != nil
   918  }
   919  
   920  func (p *NullServiceNullTestResult) Read(iprot thrift.TProtocol) (err error) {
   921  
   922  	var fieldTypeId thrift.TType
   923  	var fieldId int16
   924  
   925  	if _, err = iprot.ReadStructBegin(); err != nil {
   926  		goto ReadStructBeginError
   927  	}
   928  
   929  	for {
   930  		_, fieldTypeId, fieldId, err = iprot.ReadFieldBegin()
   931  		if err != nil {
   932  			goto ReadFieldBeginError
   933  		}
   934  		if fieldTypeId == thrift.STOP {
   935  			break
   936  		}
   937  
   938  		switch fieldId {
   939  		case 0:
   940  			if fieldTypeId == thrift.STRUCT {
   941  				if err = p.ReadField0(iprot); err != nil {
   942  					goto ReadFieldError
   943  				}
   944  			} else {
   945  				if err = iprot.Skip(fieldTypeId); err != nil {
   946  					goto SkipFieldError
   947  				}
   948  			}
   949  		default:
   950  			if err = iprot.Skip(fieldTypeId); err != nil {
   951  				goto SkipFieldError
   952  			}
   953  		}
   954  
   955  		if err = iprot.ReadFieldEnd(); err != nil {
   956  			goto ReadFieldEndError
   957  		}
   958  	}
   959  	if err = iprot.ReadStructEnd(); err != nil {
   960  		goto ReadStructEndError
   961  	}
   962  
   963  	return nil
   964  ReadStructBeginError:
   965  	return thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
   966  ReadFieldBeginError:
   967  	return thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
   968  ReadFieldError:
   969  	return thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_NullServiceNullTestResult[fieldId]), err)
   970  SkipFieldError:
   971  	return thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
   972  
   973  ReadFieldEndError:
   974  	return thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
   975  ReadStructEndError:
   976  	return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
   977  }
   978  
   979  func (p *NullServiceNullTestResult) ReadField0(iprot thrift.TProtocol) error {
   980  	p.Success = NewNullStruct()
   981  	if err := p.Success.Read(iprot); err != nil {
   982  		return err
   983  	}
   984  	return nil
   985  }
   986  
   987  func (p *NullServiceNullTestResult) Write(oprot thrift.TProtocol) (err error) {
   988  	var fieldId int16
   989  	if err = oprot.WriteStructBegin("NullTest_result"); err != nil {
   990  		goto WriteStructBeginError
   991  	}
   992  	if p != nil {
   993  		if err = p.writeField0(oprot); err != nil {
   994  			fieldId = 0
   995  			goto WriteFieldError
   996  		}
   997  
   998  	}
   999  	if err = oprot.WriteFieldStop(); err != nil {
  1000  		goto WriteFieldStopError
  1001  	}
  1002  	if err = oprot.WriteStructEnd(); err != nil {
  1003  		goto WriteStructEndError
  1004  	}
  1005  	return nil
  1006  WriteStructBeginError:
  1007  	return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
  1008  WriteFieldError:
  1009  	return thrift.PrependError(fmt.Sprintf("%T write field %d error: ", p, fieldId), err)
  1010  WriteFieldStopError:
  1011  	return thrift.PrependError(fmt.Sprintf("%T write field stop error: ", p), err)
  1012  WriteStructEndError:
  1013  	return thrift.PrependError(fmt.Sprintf("%T write struct end error: ", p), err)
  1014  }
  1015  
  1016  func (p *NullServiceNullTestResult) writeField0(oprot thrift.TProtocol) (err error) {
  1017  	if p.IsSetSuccess() {
  1018  		if err = oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil {
  1019  			goto WriteFieldBeginError
  1020  		}
  1021  		if err := p.Success.Write(oprot); err != nil {
  1022  			return err
  1023  		}
  1024  		if err = oprot.WriteFieldEnd(); err != nil {
  1025  			goto WriteFieldEndError
  1026  		}
  1027  	}
  1028  	return nil
  1029  WriteFieldBeginError:
  1030  	return thrift.PrependError(fmt.Sprintf("%T write field 0 begin error: ", p), err)
  1031  WriteFieldEndError:
  1032  	return thrift.PrependError(fmt.Sprintf("%T write field 0 end error: ", p), err)
  1033  }
  1034  
  1035  func (p *NullServiceNullTestResult) String() string {
  1036  	if p == nil {
  1037  		return "<nil>"
  1038  	}
  1039  	return fmt.Sprintf("NullServiceNullTestResult(%+v)", *p)
  1040  }
  1041  
  1042  func (p *NullServiceNullTestResult) DeepEqual(ano *NullServiceNullTestResult) bool {
  1043  	if p == ano {
  1044  		return true
  1045  	} else if p == nil || ano == nil {
  1046  		return false
  1047  	}
  1048  	if !p.Field0DeepEqual(ano.Success) {
  1049  		return false
  1050  	}
  1051  	return true
  1052  }
  1053  
  1054  func (p *NullServiceNullTestResult) Field0DeepEqual(src *NullStruct) bool {
  1055  
  1056  	if !p.Success.DeepEqual(src) {
  1057  		return false
  1058  	}
  1059  	return true
  1060  }