*: fix a few small issues identified by go vet

This commit is contained in:
Jonathan Boulle 2014-09-08 23:37:36 -07:00
parent 55b4267c30
commit 9997c9488a
4 changed files with 11 additions and 6 deletions

View File

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

View File

@ -168,7 +168,12 @@ func (l *raftLog) compact(i int64) 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 {

View File

@ -518,14 +518,14 @@ func TestHandleMsgApp(t *testing.T) {
}
m := sm.ReadMessages()
if len(m) != 1 {
t.Errorf("#%d: msg = nil, want 1")
t.Errorf("#%d: msg = nil, want 1", i)
}
gaccept := true
if m[0].Index == -1 {
gaccept = false
}
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 {
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)
}
}
}

View File

@ -313,7 +313,7 @@ func TestRecoverAfterCut(t *testing.T) {
continue
}
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 {
if e.Index != int64(j+i+1) {