Skip to content

Instantly share code, notes, and snippets.

@BytedanceRPC
BytedanceRPC / my.go.diff
Created January 19, 2021 14:53
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]) {
@BytedanceRPC
BytedanceRPC / my.go
Created January 19, 2021 14:39
new writeField1
func (p *Simple) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) {
if err := oprot.WriteFieldBegin(ctx, "DoubleSet", thrift.SET, 1); err != nil {
return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:DoubleSet: ", p), err)
}
if err := oprot.WriteSetBegin(ctx, thrift.DOUBLE, len(p.DoubleSet)); err != nil {
return thrift.PrependError("error writing set begin: ", err)
}
for i := 0; i < len(p.DoubleSet); i++ {
for j := i + 1; j < len(p.DoubleSet); j++ {
if !func(tgt, src float64) bool {