diff --git a/etcdserver/etcdhttp/http.go b/etcdserver/etcdhttp/http.go index dc2c5322a..94b455fec 100644 --- a/etcdserver/etcdhttp/http.go +++ b/etcdserver/etcdhttp/http.go @@ -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 diff --git a/raft/log.go b/raft/log.go index a971b0ab3..40c49ecea 100644 --- a/raft/log.go +++ b/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) { - 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 { diff --git a/raft/raft_test.go b/raft/raft_test.go index bcd8e075b..ddf612aaf 100644 --- a/raft/raft_test.go +++ b/raft/raft_test.go @@ -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) } } } diff --git a/wal/wal_test.go b/wal/wal_test.go index cbe058f2d..3ebed3361 100644 --- a/wal/wal_test.go +++ b/wal/wal_test.go @@ -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) {