Просмотр исходного кода

clientv3: copy correct pointers into txn comparisons

Was copying the range variable's pointer; all elements of cmp were the same.
Anthony Romano 10 лет назад
Родитель
Сommit
7b82576b60
1 измененных файлов с 2 добавлено и 2 удалено
  1. 2 2
      clientv3/txn.go

+ 2 - 2
clientv3/txn.go

@@ -85,8 +85,8 @@ func (txn *txn) If(cs ...Cmp) Txn {
 
 	txn.cif = true
 
-	for _, cmp := range cs {
-		txn.cmps = append(txn.cmps, (*pb.Compare)(&cmp))
+	for i := range cs {
+		txn.cmps = append(txn.cmps, (*pb.Compare)(&cs[i]))
 	}
 
 	return txn