*: fix go vet reported issues

This commit is contained in:
Cong Ding
2015-08-22 12:07:53 -05:00
parent 044b23c3ca
commit c09b667d57
6 changed files with 5 additions and 8 deletions

View File

@ -50,5 +50,4 @@ func (h *handler) Txn(ctx context.Context, r *pb.TxnRequest) (*pb.TxnResponse, e
func (h *handler) Compact(ctx context.Context, r *pb.CompactionRequest) (*pb.CompactionResponse, error) { func (h *handler) Compact(ctx context.Context, r *pb.CompactionRequest) (*pb.CompactionResponse, error) {
panic("not implemented") panic("not implemented")
return nil, nil
} }

View File

@ -35,12 +35,10 @@ func (ph *PauseableHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
hj, ok := w.(http.Hijacker) hj, ok := w.(http.Hijacker)
if !ok { if !ok {
panic("webserver doesn't support hijacking") panic("webserver doesn't support hijacking")
return
} }
conn, _, err := hj.Hijack() conn, _, err := hj.Hijack()
if err != nil { if err != nil {
panic(err.Error()) panic(err.Error())
return
} }
conn.Close() conn.Close()
} }

View File

@ -32,7 +32,7 @@ func TestNetworkDrop(t *testing.T) {
drop := sent - received drop := sent - received
if drop > int((droprate+0.1)*float64(sent)) || drop < int((droprate-0.1)*float64(sent)) { if drop > int((droprate+0.1)*float64(sent)) || drop < int((droprate-0.1)*float64(sent)) {
t.Errorf("drop = %d, want around %d", drop, droprate*float64(sent)) t.Errorf("drop = %d, want around %.2f", drop, droprate*float64(sent))
} }
} }

View File

@ -130,7 +130,7 @@ func (ki *keyIndex) get(atRev int64) (modified, created revision, ver int64, err
// If a generation becomes empty during compaction, it will be removed. // If a generation becomes empty during compaction, it will be removed.
func (ki *keyIndex) compact(atRev int64, available map[revision]struct{}) { func (ki *keyIndex) compact(atRev int64, available map[revision]struct{}) {
if ki.isEmpty() { if ki.isEmpty() {
log.Panic("store.keyindex: unexpected compact on empty keyIndex %s", string(ki.key)) log.Panicf("store.keyindex: unexpected compact on empty keyIndex %s", string(ki.key))
} }
// walk until reaching the first revision that has an revision smaller or equal to // walk until reaching the first revision that has an revision smaller or equal to

View File

@ -293,14 +293,14 @@ func TestKeyIndexCompact(t *testing.T) {
// Jump Compaction // Jump Compaction
for i, tt := range tests { for i, tt := range tests {
if (i%2 == 0 && i < 6) && (i%2 == 1 && i > 6) { if (i%2 == 0 && i < 6) || (i%2 == 1 && i > 6) {
am := make(map[revision]struct{}) am := make(map[revision]struct{})
ki.compact(tt.compact, am) ki.compact(tt.compact, am)
if !reflect.DeepEqual(ki, tt.wki) { if !reflect.DeepEqual(ki, tt.wki) {
t.Errorf("#%d: ki = %+v, want %+v", i, ki, tt.wki) t.Errorf("#%d: ki = %+v, want %+v", i, ki, tt.wki)
} }
if !reflect.DeepEqual(am, tt.wam) { if !reflect.DeepEqual(am, tt.wam) {
t.Errorf("#%d: am = %+v, want %+v", am, tt.wam) t.Errorf("#%d: am = %+v, want %+v", i, am, tt.wam)
} }
} }
} }

View File

@ -42,7 +42,7 @@ func TestWorkflow(t *testing.T) {
// check existing keys // check existing keys
kvs, rev, err := s.Range([]byte("bar"), []byte("bas"), 0, 0) kvs, rev, err := s.Range([]byte("bar"), []byte("bas"), 0, 0)
if err != nil { if err != nil {
t.Errorf("#%d: range error (%v)", err) t.Errorf("#%d: range error (%v)", i, err)
} }
if len(kvs) != len(wkvs) { if len(kvs) != len(wkvs) {
t.Fatalf("#%d: len(kvs) = %d, want %d", i, len(kvs), len(wkvs)) t.Fatalf("#%d: len(kvs) = %d, want %d", i, len(kvs), len(wkvs))