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

*: fix a few small issues identified by go vet

Jonathan Boulle 11 лет назад
Родитель
Сommit
9997c9488a
4 измененных файлов с 11 добавлено и 6 удалено
  1. 1 1
      etcdserver/etcdhttp/http.go
  2. 6 1
      raft/log.go
  3. 3 3
      raft/raft_test.go
  4. 1 1
      wal/wal_test.go

+ 1 - 1
etcdserver/etcdhttp/http.go

@@ -68,7 +68,7 @@ func (ps *Peers) String() string {
 
 
 func (ps Peers) Ids() []int64 {
 func (ps Peers) Ids() []int64 {
 	var ids []int64
 	var ids []int64
-	for id, _ := range ps {
+	for id := range ps {
 		ids = append(ids, id)
 		ids = append(ids, id)
 	}
 	}
 	return ids
 	return ids

+ 6 - 1
raft/log.go

@@ -168,7 +168,12 @@ func (l *raftLog) compact(i int64) int64 {
 }
 }
 
 
 func (l *raftLog) snap(d []byte, index, term int64, nodes []int64) {
 func (l *raftLog) snap(d []byte, index, term int64, nodes []int64) {
-	l.snapshot = pb.Snapshot{d, nodes, index, term, nil}
+	l.snapshot = pb.Snapshot{
+		Data:  d,
+		Nodes: nodes,
+		Index: index,
+		Term:  term,
+	}
 }
 }
 
 
 func (l *raftLog) shouldCompact() bool {
 func (l *raftLog) shouldCompact() bool {

+ 3 - 3
raft/raft_test.go

@@ -518,14 +518,14 @@ func TestHandleMsgApp(t *testing.T) {
 		}
 		}
 		m := sm.ReadMessages()
 		m := sm.ReadMessages()
 		if len(m) != 1 {
 		if len(m) != 1 {
-			t.Errorf("#%d: msg = nil, want 1")
+			t.Errorf("#%d: msg = nil, want 1", i)
 		}
 		}
 		gaccept := true
 		gaccept := true
 		if m[0].Index == -1 {
 		if m[0].Index == -1 {
 			gaccept = false
 			gaccept = false
 		}
 		}
 		if gaccept != tt.wAccept {
 		if gaccept != tt.wAccept {
-			t.Errorf("#%d: accept = %v, want %v", gaccept, tt.wAccept)
+			t.Errorf("#%d: accept = %v, want %v", i, gaccept, tt.wAccept)
 		}
 		}
 	}
 	}
 }
 }
@@ -764,7 +764,7 @@ func TestRecvMsgBeat(t *testing.T) {
 		}
 		}
 		for _, m := range msgs {
 		for _, m := range msgs {
 			if m.Type != msgApp {
 			if m.Type != msgApp {
-				t.Errorf("%d: msg.type = %v, want %v", m.Type, msgApp)
+				t.Errorf("%d: msg.type = %v, want %v", i, m.Type, msgApp)
 			}
 			}
 		}
 		}
 	}
 	}

+ 1 - 1
wal/wal_test.go

@@ -313,7 +313,7 @@ func TestRecoverAfterCut(t *testing.T) {
 			continue
 			continue
 		}
 		}
 		if id != info.Id {
 		if id != info.Id {
-			t.Errorf("#%d: id = %d, want %d", id, info.Id)
+			t.Errorf("#%d: id = %d, want %d", i, id, info.Id)
 		}
 		}
 		for j, e := range entries {
 		for j, e := range entries {
 			if e.Index != int64(j+i+1) {
 			if e.Index != int64(j+i+1) {