update thrift test files to 0.14.0

This commit is contained in:
smallnest
2021-03-02 08:28:32 +08:00
parent 6a1c02735e
commit a584f8a716
6 changed files with 558 additions and 524 deletions

View File

@@ -1,7 +1,5 @@
// Autogenerated by Thrift Compiler (0.11.0)
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
package testutils
var GoUnusedProtection__ int;
// Code generated by Thrift Compiler (0.14.0). DO NOT EDIT.
package testutils
var GoUnusedProtection__ int

View File

@@ -1,23 +1,21 @@
// Autogenerated by Thrift Compiler (0.11.0)
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
package testutils
import (
"bytes"
"context"
"fmt"
"reflect"
"github.com/apache/thrift/lib/go/thrift"
)
// (needed to ensure safety because of naive import list construction.)
var _ = thrift.ZERO
var _ = fmt.Printf
var _ = context.Background
var _ = reflect.DeepEqual
var _ = bytes.Equal
func init() {
}
// Code generated by Thrift Compiler (0.14.0). DO NOT EDIT.
package testutils
import (
"bytes"
"context"
"fmt"
"github.com/apache/thrift/lib/go/thrift"
"time"
)
// (needed to ensure safety because of naive import list construction.)
var _ = thrift.ZERO
var _ = fmt.Printf
var _ = context.Background
var _ = time.Now
var _ = bytes.Equal
func init() {
}

View File

@@ -1,259 +1,284 @@
// Autogenerated by Thrift Compiler (0.11.0)
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
package testutils
import (
"bytes"
"context"
"fmt"
"reflect"
"github.com/apache/thrift/lib/go/thrift"
)
// (needed to ensure safety because of naive import list construction.)
var _ = thrift.ZERO
var _ = fmt.Printf
var _ = context.Background
var _ = reflect.DeepEqual
var _ = bytes.Equal
// Attributes:
// - A
// - B
type ThriftArgs_ struct {
A int32 `thrift:"a,1" db:"a" json:"a"`
B int32 `thrift:"b,2" db:"b" json:"b"`
}
func NewThriftArgs_() *ThriftArgs_ {
return &ThriftArgs_{}
}
func (p *ThriftArgs_) GetA() int32 {
return p.A
}
func (p *ThriftArgs_) GetB() int32 {
return p.B
}
func (p *ThriftArgs_) Read(iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP {
break
}
switch fieldId {
case 1:
if fieldTypeId == thrift.I32 {
if err := p.ReadField1(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 2:
if fieldTypeId == thrift.I32 {
if err := p.ReadField2(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *ThriftArgs_) ReadField1(iprot thrift.TProtocol) error {
if v, err := iprot.ReadI32(); err != nil {
return thrift.PrependError("error reading field 1: ", err)
} else {
p.A = v
}
return nil
}
func (p *ThriftArgs_) ReadField2(iprot thrift.TProtocol) error {
if v, err := iprot.ReadI32(); err != nil {
return thrift.PrependError("error reading field 2: ", err)
} else {
p.B = v
}
return nil
}
func (p *ThriftArgs_) Write(oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin("ThriftArgs"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
}
if p != nil {
if err := p.writeField1(oprot); err != nil {
return err
}
if err := p.writeField2(oprot); err != nil {
return err
}
}
if err := oprot.WriteFieldStop(); err != nil {
return thrift.PrependError("write field stop error: ", err)
}
if err := oprot.WriteStructEnd(); err != nil {
return thrift.PrependError("write struct stop error: ", err)
}
return nil
}
func (p *ThriftArgs_) writeField1(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("a", thrift.I32, 1); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:a: ", p), err)
}
if err := oprot.WriteI32(int32(p.A)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.a (1) field write error: ", p), err)
}
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 1:a: ", p), err)
}
return err
}
func (p *ThriftArgs_) writeField2(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("b", thrift.I32, 2); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:b: ", p), err)
}
if err := oprot.WriteI32(int32(p.B)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.b (2) field write error: ", p), err)
}
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 2:b: ", p), err)
}
return err
}
func (p *ThriftArgs_) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("ThriftArgs_(%+v)", *p)
}
// Attributes:
// - C
type ThriftReply struct {
C int32 `thrift:"c,1" db:"c" json:"c"`
}
func NewThriftReply() *ThriftReply {
return &ThriftReply{}
}
func (p *ThriftReply) GetC() int32 {
return p.C
}
func (p *ThriftReply) Read(iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP {
break
}
switch fieldId {
case 1:
if fieldTypeId == thrift.I32 {
if err := p.ReadField1(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *ThriftReply) ReadField1(iprot thrift.TProtocol) error {
if v, err := iprot.ReadI32(); err != nil {
return thrift.PrependError("error reading field 1: ", err)
} else {
p.C = v
}
return nil
}
func (p *ThriftReply) Write(oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin("ThriftReply"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
}
if p != nil {
if err := p.writeField1(oprot); err != nil {
return err
}
}
if err := oprot.WriteFieldStop(); err != nil {
return thrift.PrependError("write field stop error: ", err)
}
if err := oprot.WriteStructEnd(); err != nil {
return thrift.PrependError("write struct stop error: ", err)
}
return nil
}
func (p *ThriftReply) writeField1(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("c", thrift.I32, 1); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:c: ", p), err)
}
if err := oprot.WriteI32(int32(p.C)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.c (1) field write error: ", p), err)
}
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 1:c: ", p), err)
}
return err
}
func (p *ThriftReply) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("ThriftReply(%+v)", *p)
}
// Code generated by Thrift Compiler (0.14.0). DO NOT EDIT.
package testutils
import (
"bytes"
"context"
"fmt"
"github.com/apache/thrift/lib/go/thrift"
"time"
)
// (needed to ensure safety because of naive import list construction.)
var _ = thrift.ZERO
var _ = fmt.Printf
var _ = context.Background
var _ = time.Now
var _ = bytes.Equal
// Attributes:
// - A
// - B
type ThriftArgs_ struct {
A int32 `thrift:"a,1" db:"a" json:"a"`
B int32 `thrift:"b,2" db:"b" json:"b"`
}
func NewThriftArgs_() *ThriftArgs_ {
return &ThriftArgs_{}
}
func (p *ThriftArgs_) GetA() int32 {
return p.A
}
func (p *ThriftArgs_) GetB() int32 {
return p.B
}
func (p *ThriftArgs_) Read(ctx context.Context, iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(ctx); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP {
break
}
switch fieldId {
case 1:
if fieldTypeId == thrift.I32 {
if err := p.ReadField1(ctx, iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(ctx, fieldTypeId); err != nil {
return err
}
}
case 2:
if fieldTypeId == thrift.I32 {
if err := p.ReadField2(ctx, iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(ctx, fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(ctx, fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(ctx); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(ctx); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *ThriftArgs_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error {
if v, err := iprot.ReadI32(ctx); err != nil {
return thrift.PrependError("error reading field 1: ", err)
} else {
p.A = v
}
return nil
}
func (p *ThriftArgs_) ReadField2(ctx context.Context, iprot thrift.TProtocol) error {
if v, err := iprot.ReadI32(ctx); err != nil {
return thrift.PrependError("error reading field 2: ", err)
} else {
p.B = v
}
return nil
}
func (p *ThriftArgs_) Write(ctx context.Context, oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin(ctx, "ThriftArgs"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
}
if p != nil {
if err := p.writeField1(ctx, oprot); err != nil {
return err
}
if err := p.writeField2(ctx, oprot); err != nil {
return err
}
}
if err := oprot.WriteFieldStop(ctx); err != nil {
return thrift.PrependError("write field stop error: ", err)
}
if err := oprot.WriteStructEnd(ctx); err != nil {
return thrift.PrependError("write struct stop error: ", err)
}
return nil
}
func (p *ThriftArgs_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin(ctx, "a", thrift.I32, 1); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:a: ", p), err)
}
if err := oprot.WriteI32(ctx, int32(p.A)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.a (1) field write error: ", p), err)
}
if err := oprot.WriteFieldEnd(ctx); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 1:a: ", p), err)
}
return err
}
func (p *ThriftArgs_) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin(ctx, "b", thrift.I32, 2); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:b: ", p), err)
}
if err := oprot.WriteI32(ctx, int32(p.B)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.b (2) field write error: ", p), err)
}
if err := oprot.WriteFieldEnd(ctx); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 2:b: ", p), err)
}
return err
}
func (p *ThriftArgs_) Equals(other *ThriftArgs_) bool {
if p == other {
return true
} else if p == nil || other == nil {
return false
}
if p.A != other.A {
return false
}
if p.B != other.B {
return false
}
return true
}
func (p *ThriftArgs_) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("ThriftArgs_(%+v)", *p)
}
// Attributes:
// - C
type ThriftReply struct {
C int32 `thrift:"c,1" db:"c" json:"c"`
}
func NewThriftReply() *ThriftReply {
return &ThriftReply{}
}
func (p *ThriftReply) GetC() int32 {
return p.C
}
func (p *ThriftReply) Read(ctx context.Context, iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(ctx); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP {
break
}
switch fieldId {
case 1:
if fieldTypeId == thrift.I32 {
if err := p.ReadField1(ctx, iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(ctx, fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(ctx, fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(ctx); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(ctx); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *ThriftReply) ReadField1(ctx context.Context, iprot thrift.TProtocol) error {
if v, err := iprot.ReadI32(ctx); err != nil {
return thrift.PrependError("error reading field 1: ", err)
} else {
p.C = v
}
return nil
}
func (p *ThriftReply) Write(ctx context.Context, oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin(ctx, "ThriftReply"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err)
}
if p != nil {
if err := p.writeField1(ctx, oprot); err != nil {
return err
}
}
if err := oprot.WriteFieldStop(ctx); err != nil {
return thrift.PrependError("write field stop error: ", err)
}
if err := oprot.WriteStructEnd(ctx); err != nil {
return thrift.PrependError("write struct stop error: ", err)
}
return nil
}
func (p *ThriftReply) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin(ctx, "c", thrift.I32, 1); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:c: ", p), err)
}
if err := oprot.WriteI32(ctx, int32(p.C)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.c (1) field write error: ", p), err)
}
if err := oprot.WriteFieldEnd(ctx); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 1:c: ", p), err)
}
return err
}
func (p *ThriftReply) Equals(other *ThriftReply) bool {
if p == other {
return true
} else if p == nil || other == nil {
return false
}
if p.C != other.C {
return false
}
return true
}
func (p *ThriftReply) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("ThriftReply(%+v)", *p)
}

View File

@@ -1,7 +1,6 @@
// Autogenerated by Thrift Compiler (0.13.0)
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
package testdata
var GoUnusedProtection__ int;
// Code generated by Thrift Compiler (0.14.0). DO NOT EDIT.
package testdata
var GoUnusedProtection__ int;

View File

@@ -1,24 +1,23 @@
// Autogenerated by Thrift Compiler (0.13.0)
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
package testdata
import(
"bytes"
"context"
"reflect"
"fmt"
"github.com/apache/thrift/lib/go/thrift"
)
// (needed to ensure safety because of naive import list construction.)
var _ = thrift.ZERO
var _ = fmt.Printf
var _ = context.Background
var _ = reflect.DeepEqual
var _ = bytes.Equal
func init() {
}
// Code generated by Thrift Compiler (0.14.0). DO NOT EDIT.
package testdata
import(
"bytes"
"context"
"fmt"
"time"
"github.com/apache/thrift/lib/go/thrift"
)
// (needed to ensure safety because of naive import list construction.)
var _ = thrift.ZERO
var _ = fmt.Printf
var _ = context.Background
var _ = time.Now
var _ = bytes.Equal
func init() {
}

View File

@@ -1,204 +1,219 @@
// Autogenerated by Thrift Compiler (0.13.0)
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
package testdata
import(
"bytes"
"context"
"reflect"
"fmt"
"github.com/apache/thrift/lib/go/thrift"
)
// (needed to ensure safety because of naive import list construction.)
var _ = thrift.ZERO
var _ = fmt.Printf
var _ = context.Background
var _ = reflect.DeepEqual
var _ = bytes.Equal
// Attributes:
// - ID
// - Name
// - Colors
type ThriftColorGroup struct {
ID int32 `thrift:"id,1" db:"id" json:"id"`
Name string `thrift:"name,2" db:"name" json:"name"`
Colors []string `thrift:"colors,3" db:"colors" json:"colors"`
}
func NewThriftColorGroup() *ThriftColorGroup {
return &ThriftColorGroup{}
}
func (p *ThriftColorGroup) GetID() int32 {
return p.ID
}
func (p *ThriftColorGroup) GetName() string {
return p.Name
}
func (p *ThriftColorGroup) GetColors() []string {
return p.Colors
}
func (p *ThriftColorGroup) Read(iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin()
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP { break; }
switch fieldId {
case 1:
if fieldTypeId == thrift.I32 {
if err := p.ReadField1(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 2:
if fieldTypeId == thrift.STRING {
if err := p.ReadField2(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
case 3:
if fieldTypeId == thrift.LIST {
if err := p.ReadField3(iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *ThriftColorGroup) ReadField1(iprot thrift.TProtocol) error {
if v, err := iprot.ReadI32(); err != nil {
return thrift.PrependError("error reading field 1: ", err)
} else {
p.ID = v
}
return nil
}
func (p *ThriftColorGroup) ReadField2(iprot thrift.TProtocol) error {
if v, err := iprot.ReadString(); err != nil {
return thrift.PrependError("error reading field 2: ", err)
} else {
p.Name = v
}
return nil
}
func (p *ThriftColorGroup) ReadField3(iprot thrift.TProtocol) error {
_, size, err := iprot.ReadListBegin()
if err != nil {
return thrift.PrependError("error reading list begin: ", err)
}
tSlice := make([]string, 0, size)
p.Colors = tSlice
for i := 0; i < size; i ++ {
var _elem0 string
if v, err := iprot.ReadString(); err != nil {
return thrift.PrependError("error reading field 0: ", err)
} else {
_elem0 = v
}
p.Colors = append(p.Colors, _elem0)
}
if err := iprot.ReadListEnd(); err != nil {
return thrift.PrependError("error reading list end: ", err)
}
return nil
}
func (p *ThriftColorGroup) Write(oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin("ThriftColorGroup"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
if p != nil {
if err := p.writeField1(oprot); err != nil { return err }
if err := p.writeField2(oprot); err != nil { return err }
if err := p.writeField3(oprot); err != nil { return err }
}
if err := oprot.WriteFieldStop(); err != nil {
return thrift.PrependError("write field stop error: ", err) }
if err := oprot.WriteStructEnd(); err != nil {
return thrift.PrependError("write struct stop error: ", err) }
return nil
}
func (p *ThriftColorGroup) writeField1(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("id", thrift.I32, 1); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:id: ", p), err) }
if err := oprot.WriteI32(int32(p.ID)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.id (1) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 1:id: ", p), err) }
return err
}
func (p *ThriftColorGroup) writeField2(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("name", thrift.STRING, 2); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:name: ", p), err) }
if err := oprot.WriteString(string(p.Name)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.name (2) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 2:name: ", p), err) }
return err
}
func (p *ThriftColorGroup) writeField3(oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin("colors", thrift.LIST, 3); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:colors: ", p), err) }
if err := oprot.WriteListBegin(thrift.STRING, len(p.Colors)); err != nil {
return thrift.PrependError("error writing list begin: ", err)
}
for _, v := range p.Colors {
if err := oprot.WriteString(string(v)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) }
}
if err := oprot.WriteListEnd(); err != nil {
return thrift.PrependError("error writing list end: ", err)
}
if err := oprot.WriteFieldEnd(); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 3:colors: ", p), err) }
return err
}
func (p *ThriftColorGroup) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("ThriftColorGroup(%+v)", *p)
}
// Code generated by Thrift Compiler (0.14.0). DO NOT EDIT.
package testdata
import(
"bytes"
"context"
"fmt"
"time"
"github.com/apache/thrift/lib/go/thrift"
)
// (needed to ensure safety because of naive import list construction.)
var _ = thrift.ZERO
var _ = fmt.Printf
var _ = context.Background
var _ = time.Now
var _ = bytes.Equal
// Attributes:
// - ID
// - Name
// - Colors
type ThriftColorGroup struct {
ID int32 `thrift:"id,1" db:"id" json:"id"`
Name string `thrift:"name,2" db:"name" json:"name"`
Colors []string `thrift:"colors,3" db:"colors" json:"colors"`
}
func NewThriftColorGroup() *ThriftColorGroup {
return &ThriftColorGroup{}
}
func (p *ThriftColorGroup) GetID() int32 {
return p.ID
}
func (p *ThriftColorGroup) GetName() string {
return p.Name
}
func (p *ThriftColorGroup) GetColors() []string {
return p.Colors
}
func (p *ThriftColorGroup) Read(ctx context.Context, iprot thrift.TProtocol) error {
if _, err := iprot.ReadStructBegin(ctx); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err)
}
for {
_, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx)
if err != nil {
return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err)
}
if fieldTypeId == thrift.STOP { break; }
switch fieldId {
case 1:
if fieldTypeId == thrift.I32 {
if err := p.ReadField1(ctx, iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(ctx, fieldTypeId); err != nil {
return err
}
}
case 2:
if fieldTypeId == thrift.STRING {
if err := p.ReadField2(ctx, iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(ctx, fieldTypeId); err != nil {
return err
}
}
case 3:
if fieldTypeId == thrift.LIST {
if err := p.ReadField3(ctx, iprot); err != nil {
return err
}
} else {
if err := iprot.Skip(ctx, fieldTypeId); err != nil {
return err
}
}
default:
if err := iprot.Skip(ctx, fieldTypeId); err != nil {
return err
}
}
if err := iprot.ReadFieldEnd(ctx); err != nil {
return err
}
}
if err := iprot.ReadStructEnd(ctx); err != nil {
return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
}
return nil
}
func (p *ThriftColorGroup) ReadField1(ctx context.Context, iprot thrift.TProtocol) error {
if v, err := iprot.ReadI32(ctx); err != nil {
return thrift.PrependError("error reading field 1: ", err)
} else {
p.ID = v
}
return nil
}
func (p *ThriftColorGroup) ReadField2(ctx context.Context, iprot thrift.TProtocol) error {
if v, err := iprot.ReadString(ctx); err != nil {
return thrift.PrependError("error reading field 2: ", err)
} else {
p.Name = v
}
return nil
}
func (p *ThriftColorGroup) ReadField3(ctx context.Context, iprot thrift.TProtocol) error {
_, size, err := iprot.ReadListBegin(ctx)
if err != nil {
return thrift.PrependError("error reading list begin: ", err)
}
tSlice := make([]string, 0, size)
p.Colors = tSlice
for i := 0; i < size; i ++ {
var _elem0 string
if v, err := iprot.ReadString(ctx); err != nil {
return thrift.PrependError("error reading field 0: ", err)
} else {
_elem0 = v
}
p.Colors = append(p.Colors, _elem0)
}
if err := iprot.ReadListEnd(ctx); err != nil {
return thrift.PrependError("error reading list end: ", err)
}
return nil
}
func (p *ThriftColorGroup) Write(ctx context.Context, oprot thrift.TProtocol) error {
if err := oprot.WriteStructBegin(ctx, "ThriftColorGroup"); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) }
if p != nil {
if err := p.writeField1(ctx, oprot); err != nil { return err }
if err := p.writeField2(ctx, oprot); err != nil { return err }
if err := p.writeField3(ctx, oprot); err != nil { return err }
}
if err := oprot.WriteFieldStop(ctx); err != nil {
return thrift.PrependError("write field stop error: ", err) }
if err := oprot.WriteStructEnd(ctx); err != nil {
return thrift.PrependError("write struct stop error: ", err) }
return nil
}
func (p *ThriftColorGroup) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin(ctx, "id", thrift.I32, 1); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:id: ", p), err) }
if err := oprot.WriteI32(ctx, int32(p.ID)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.id (1) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(ctx); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 1:id: ", p), err) }
return err
}
func (p *ThriftColorGroup) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin(ctx, "name", thrift.STRING, 2); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:name: ", p), err) }
if err := oprot.WriteString(ctx, string(p.Name)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T.name (2) field write error: ", p), err) }
if err := oprot.WriteFieldEnd(ctx); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 2:name: ", p), err) }
return err
}
func (p *ThriftColorGroup) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin(ctx, "colors", thrift.LIST, 3); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:colors: ", p), err) }
if err := oprot.WriteListBegin(ctx, thrift.STRING, len(p.Colors)); err != nil {
return thrift.PrependError("error writing list begin: ", err)
}
for _, v := range p.Colors {
if err := oprot.WriteString(ctx, string(v)); err != nil {
return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) }
}
if err := oprot.WriteListEnd(ctx); err != nil {
return thrift.PrependError("error writing list end: ", err)
}
if err := oprot.WriteFieldEnd(ctx); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field end error 3:colors: ", p), err) }
return err
}
func (p *ThriftColorGroup) Equals(other *ThriftColorGroup) bool {
if p == other {
return true
} else if p == nil || other == nil {
return false
}
if p.ID != other.ID { return false }
if p.Name != other.Name { return false }
if len(p.Colors) != len(other.Colors) { return false }
for i, _tgt := range p.Colors {
_src1 := other.Colors[i]
if _tgt != _src1 { return false }
}
return true
}
func (p *ThriftColorGroup) String() string {
if p == nil {
return "<nil>"
}
return fmt.Sprintf("ThriftColorGroup(%+v)", *p)
}