Skip to content

Instantly share code, notes, and snippets.

@BytedanceRPC
Created January 19, 2021 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BytedanceRPC/1aa34b65cf4c9efabed0d0a115262d85 to your computer and use it in GitHub Desktop.
Save BytedanceRPC/1aa34b65cf4c9efabed0d0a115262d85 to your computer and use it in GitHub Desktop.
my.go diff
123,124c123,129
< if reflect.DeepEqual(p.DoubleSet[i], p.DoubleSet[j]) {
< return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", p.DoubleSet[i]))
---
> if !func(tgt, src float64) bool {
> if tgt != src {
> return false
> }
> return true
> }(p.DoubleSet[i], p.DoubleSet[j]) {
> return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", p.DoubleSet))
141a147,161
> func (p *Simple) Equals(other *Simple) bool {
> if p == other {
> return true
> } else if p == nil || other == nil {
> return false
> }
> for i, _tgt := range p.DoubleSet {
> _src1 := other.DoubleSet[i]
> if _tgt != _src1 {
> return false
> }
> }
> return true
> }
>
209c229
< var _elem1 int64
---
> var _elem2 int64
213c233
< _elem1 = v
---
> _elem2 = v
215c235
< p.I64Set = append(p.I64Set, _elem1)
---
> p.I64Set = append(p.I64Set, _elem2)
250,251c270,276
< if reflect.DeepEqual(p.I64Set[i], p.I64Set[j]) {
< return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", p.I64Set[i]))
---
> if !func(tgt, src int64) bool {
> if tgt != src {
> return false
> }
> return true
> }(p.I64Set[i], p.I64Set[j]) {
> return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", p.I64Set))
268a294,308
> func (p *Base) Equals(other *Base) bool {
> if p == other {
> return true
> } else if p == nil || other == nil {
> return false
> }
> for i, _tgt := range p.I64Set {
> _src3 := other.I64Set[i]
> if _tgt != _src3 {
> return false
> }
> }
> return true
> }
>
336,338c376,378
< _elem2 := &Base{}
< if err := _elem2.Read(ctx, iprot); err != nil {
< return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem2), err)
---
> _elem4 := &Base{}
> if err := _elem4.Read(ctx, iprot); err != nil {
> return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem4), err)
340c380
< p.BaseSet = append(p.BaseSet, _elem2)
---
> p.BaseSet = append(p.BaseSet, _elem4)
375,376c415,421
< if reflect.DeepEqual(p.BaseSet[i], p.BaseSet[j]) {
< return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", p.BaseSet[i]))
---
> if !func(tgt, src *Base) bool {
> if !tgt.Equals(src) {
> return false
> }
> return true
> }(p.BaseSet[i], p.BaseSet[j]) {
> return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", p.BaseSet))
393a439,453
> func (p *WrappedBase) Equals(other *WrappedBase) bool {
> if p == other {
> return true
> } else if p == nil || other == nil {
> return false
> }
> for i, _tgt := range p.BaseSet {
> _src5 := other.BaseSet[i]
> if !_tgt.Equals(_src5) {
> return false
> }
> }
> return true
> }
>
461,463c521,523
< _elem3 := &WrappedBase{}
< if err := _elem3.Read(ctx, iprot); err != nil {
< return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem3), err)
---
> _elem6 := &WrappedBase{}
> if err := _elem6.Read(ctx, iprot); err != nil {
> return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem6), err)
465c525
< p.WrappedBaseSet = append(p.WrappedBaseSet, _elem3)
---
> p.WrappedBaseSet = append(p.WrappedBaseSet, _elem6)
500,501c560,566
< if reflect.DeepEqual(p.WrappedBaseSet[i], p.WrappedBaseSet[j]) {
< return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", p.WrappedBaseSet[i]))
---
> if !func(tgt, src *WrappedBase) bool {
> if !tgt.Equals(src) {
> return false
> }
> return true
> }(p.WrappedBaseSet[i], p.WrappedBaseSet[j]) {
> return thrift.PrependError("", fmt.Errorf("%T error writing set field: slice is not unique", p.WrappedBaseSet))
516a582,596
> }
>
> func (p *Nested) Equals(other *Nested) bool {
> if p == other {
> return true
> } else if p == nil || other == nil {
> return false
> }
> for i, _tgt := range p.WrappedBaseSet {
> _src7 := other.WrappedBaseSet[i]
> if !_tgt.Equals(_src7) {
> return false
> }
> }
> return true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment