diff --git a/bps.go b/bps.go index 0138b3e..02b6e96 100644 --- a/bps.go +++ b/bps.go @@ -12,7 +12,7 @@ const ( minResolution = 3 ) -// BPS calculates bandwith rates. +// BPS calculates bandwidth rates. // // Instantiate a BPS using one of the New* functions then feed bytes either via // BPS.Add, or writing to it (it implements io.Writer). When the accumulated @@ -118,7 +118,7 @@ func (b *BPS) Add(i int64) { // Rate returns the current rate (bytes / second). func (b *BPS) Rate() float64 { b.Lock() - var total int64 = 0 + var total int64 for _, b := range b.buckets { total += b } diff --git a/bps_test.go b/bps_test.go index 7d6bb14..45af758 100644 --- a/bps_test.go +++ b/bps_test.go @@ -49,7 +49,7 @@ func TestWriter(t *testing.T) { time.Sleep(2 * time.Second) for i := 0; i < 100; i++ { if bw.Rate() > 0 { - t.Errorf("got high rate: got, want 0.0000", bw.Rate()) + t.Errorf("got high rate: got %f, want 0.0000", bw.Rate()) } time.Sleep(9 * time.Millisecond) } @@ -73,7 +73,7 @@ func TestAdd(t *testing.T) { time.Sleep(2 * time.Second) for i := 0; i < 100; i++ { if bw.Rate() > 0 { - t.Errorf("got high rate: got, want 0.0000", bw.Rate()) + t.Errorf("got high rate: got %v, want 0.0000", bw.Rate()) } time.Sleep(9 * time.Millisecond) }