From a69ce3b6a82d5a2e48d2838d6e24f656de4fa915 Mon Sep 17 00:00:00 2001 From: Sergio Arroutbi Date: Thu, 25 May 2023 16:45:16 +0200 Subject: [PATCH] Clean code and fix issues reported by staticcheck Signed-off-by: Sergio Arroutbi --- augmentedtree/atree_test.go | 2 +- bitarray/bitarray.go | 8 ++--- bitarray/block_test.go | 4 +-- bitarray/encoding.go | 8 ++--- bitarray/encoding_test.go | 2 +- btree/immutable/delete.go | 4 +-- btree/immutable/rt_test.go | 7 +++-- btree/palm/action.go | 1 - fibheap/fibheap.go | 12 +++---- fibheap/fibheap_test.go | 19 ++++++----- graph/simple.go | 4 +-- hashmap/fastinteger/hashmap_test.go | 7 +---- list/persistent.go | 2 +- rangetree/immutable.go | 16 +++------- rangetree/orderedtree.go | 16 +++------- rtree/hilbert/action.go | 4 +-- slice/skip/iterator.go | 2 -- trie/ctrie/ctrie.go | 49 +++++++++++++---------------- trie/ctrie/ctrie_test.go | 2 +- trie/dtrie/dtrie.go | 2 +- trie/dtrie/dtrie_test.go | 6 ++-- 21 files changed, 71 insertions(+), 106 deletions(-) diff --git a/augmentedtree/atree_test.go b/augmentedtree/atree_test.go index 7c96e67..a120895 100644 --- a/augmentedtree/atree_test.go +++ b/augmentedtree/atree_test.go @@ -639,7 +639,7 @@ func TestTraverse(t *testing.T) { found[id.ID()] = true }) for i := 0; i <= top; i++ { - if found, _ := found[uint64(i)]; !found { + if found := found[uint64(i)]; !found { t.Errorf("could not find expected interval %d", i) } } diff --git a/bitarray/bitarray.go b/bitarray/bitarray.go index 37e49ff..64ebd69 100644 --- a/bitarray/bitarray.go +++ b/bitarray/bitarray.go @@ -282,11 +282,7 @@ func (ba *bitArray) Equals(other BitArray) bool { } lastIndex, _ := getIndexAndRemainder(ba.highest) - if lastIndex >= selfIndex { - return false - } - - return true + return lastIndex < selfIndex } // Intersects returns a bool indicating if the supplied bitarray intersects @@ -371,7 +367,7 @@ func newBitArray(size uint64, args ...bool) *bitArray { anyset: false, } - if len(args) > 0 && args[0] == true { + if len(args) > 0 && args[0] { for i := uint64(0); i < uint64(len(ba.blocks)); i++ { ba.blocks[i] = maximumBlock } diff --git a/bitarray/block_test.go b/bitarray/block_test.go index f1c347b..e9be589 100644 --- a/bitarray/block_test.go +++ b/bitarray/block_test.go @@ -30,7 +30,7 @@ func TestBlockToNums(t *testing.T) { expected := []uint64{s - 6, s - 2} - result := make([]uint64, 0, 0) + result := make([]uint64, 0) b.toNums(0, &result) assert.Equal(t, expected, result) } @@ -41,7 +41,7 @@ func BenchmarkBlockToNums(b *testing.B) { block = block.insert(i) } - nums := make([]uint64, 0, 0) + nums := make([]uint64, 0) b.ResetTimer() for i := 0; i < b.N; i++ { diff --git a/bitarray/encoding.go b/bitarray/encoding.go index f79f9be..b61cca6 100644 --- a/bitarray/encoding.go +++ b/bitarray/encoding.go @@ -122,7 +122,7 @@ func (ret *sparseBitArray) Deserialize(incoming []byte) error { var bytesRead int intsToRead, bytesRead = Uint64FromBytes(incoming[curLoc : curLoc+intsize]) if bytesRead < 0 { - return errors.New("Invalid data for BitArray") + return errors.New("invalid data for BitArray") } curLoc += intsize @@ -131,7 +131,7 @@ func (ret *sparseBitArray) Deserialize(incoming []byte) error { for i := uint64(0); i < intsToRead; i++ { nextblock, bytesRead = Uint64FromBytes(incoming[curLoc : curLoc+intsize]) if bytesRead < 0 { - return errors.New("Invalid data for BitArray") + return errors.New("invalid data for BitArray") } ret.blocks[i] = block(nextblock) curLoc += intsize @@ -139,7 +139,7 @@ func (ret *sparseBitArray) Deserialize(incoming []byte) error { intsToRead, bytesRead = Uint64FromBytes(incoming[curLoc : curLoc+intsize]) if bytesRead < 0 { - return errors.New("Invalid data for BitArray") + return errors.New("invalid data for BitArray") } curLoc += intsize @@ -148,7 +148,7 @@ func (ret *sparseBitArray) Deserialize(incoming []byte) error { for i := uint64(0); i < intsToRead; i++ { nextuint, bytesRead = Uint64FromBytes(incoming[curLoc : curLoc+intsize]) if bytesRead < 0 { - return errors.New("Invalid data for BitArray") + return errors.New("invalid data for BitArray") } ret.indices[i] = nextuint curLoc += intsize diff --git a/bitarray/encoding_test.go b/bitarray/encoding_test.go index d915955..8de50b7 100644 --- a/bitarray/encoding_test.go +++ b/bitarray/encoding_test.go @@ -124,7 +124,7 @@ func TestUnmarshalErrors(t *testing.T) { } } - outputBytes, err := Marshal(input) + outputBytes, _ := Marshal(input) outputBytes[0] = 'C' diff --git a/btree/immutable/delete.go b/btree/immutable/delete.go index a605343..ba1feed 100644 --- a/btree/immutable/delete.go +++ b/btree/immutable/delete.go @@ -63,7 +63,7 @@ func (t *Tr) delete(keys Keys) error { pb := path.peek() node := pb.n - isRoot := bytes.Compare(node.ID, t.Root) == 0 + isRoot := bytes.Equal(node.ID, t.Root) if !t.context.nodeExists(node.ID) { cp := node.copy() t.context.addNode(cp) @@ -103,7 +103,7 @@ func (t *Tr) delete(keys Keys) error { for pb.prev != nil { parentBundle := pb.prev parent := parentBundle.n - isRoot := bytes.Compare(parent.ID, t.Root) == 0 + isRoot := bytes.Equal(parent.ID, t.Root) if !t.context.nodeExists(parent.ID) { cp := parent.copy() t.context.addNode(cp) diff --git a/btree/immutable/rt_test.go b/btree/immutable/rt_test.go index 13747e0..edab213 100644 --- a/btree/immutable/rt_test.go +++ b/btree/immutable/rt_test.go @@ -413,6 +413,7 @@ func TestNodeSplit(t *testing.T) { rt, err = mutable.Commit() require.NoError(t, err) rt, err = Load(cfg.Persister, rt.ID(), comparator) + require.NoError(t, err) result, err = mutable.(*Tr).toList(itemsToValues(items...)...) require.NoError(t, err) @@ -505,6 +506,7 @@ func TestRandom(t *testing.T) { require.NoError(t, err) expected := toOrdered(items).toItems() result, err := mutable.(*Tr).toList(itemsToValues(expected...)...) + require.NoError(t, err) if !assert.Equal(t, expected, result) { assert.Equal(t, len(expected), len(result)) for i, c := range expected { @@ -763,10 +765,11 @@ func TestSecondCommitMultipleSplits(t *testing.T) { mutable.AddItems(items[:25]...) mutable.(*Tr).verify(mutable.(*Tr).Root, t) rt, err := mutable.Commit() + require.NoError(t, err) rt.(*Tr).verify(rt.(*Tr).Root, t) - result, err := rt.(*Tr).toList(itemsToValues(items...)...) - require.Nil(t, err) + result, errToList := rt.(*Tr).toList(itemsToValues(items...)...) + require.Nil(t, errToList) assert.Equal(t, items[:25], result) mutable = rt.AsMutable() diff --git a/btree/palm/action.go b/btree/palm/action.go index e83ee59..8e33b16 100644 --- a/btree/palm/action.go +++ b/btree/palm/action.go @@ -52,7 +52,6 @@ func (ga *getAction) keys() common.Comparators { } func (ga *getAction) addNode(i int64, n *node) { - return // not necessary for gets } func (ga *getAction) nodes() []*node { diff --git a/fibheap/fibheap.go b/fibheap/fibheap.go index 1923939..59461ae 100644 --- a/fibheap/fibheap.go +++ b/fibheap/fibheap.go @@ -251,15 +251,15 @@ func (heap *FloatingFibonacciHeap) DequeueMin() (*Entry, error) { func (heap *FloatingFibonacciHeap) DecreaseKey(node *Entry, newPriority float64) (*Entry, error) { if heap.IsEmpty() { - return nil, EmptyHeapError("Cannot decrease key in an empty heap") + return nil, EmptyHeapError("cannot decrease key in an empty heap") } if node == nil { - return nil, NilError("Cannot decrease key: given node is nil") + return nil, NilError("cannot decrease key: given node is nil") } if newPriority >= node.Priority { - return nil, fmt.Errorf("The given new priority: %v, is larger than or equal to the old: %v", + return nil, fmt.Errorf("the given new priority: %v, is larger than or equal to the old: %v", newPriority, node.Priority) } @@ -271,11 +271,11 @@ func (heap *FloatingFibonacciHeap) DecreaseKey(node *Entry, newPriority float64) func (heap *FloatingFibonacciHeap) Delete(node *Entry) error { if heap.IsEmpty() { - return EmptyHeapError("Cannot delete element from an empty heap") + return EmptyHeapError("cannot delete element from an empty heap") } if node == nil { - return NilError("Cannot delete node: given node is nil") + return NilError("cannot delete node: given node is nil") } decreaseKeyUnchecked(heap, node, -math.MaxFloat64) @@ -291,7 +291,7 @@ func (heap *FloatingFibonacciHeap) Delete(node *Entry) error { func (heap *FloatingFibonacciHeap) Merge(other *FloatingFibonacciHeap) (FloatingFibonacciHeap, error) { if heap == nil || other == nil { - return FloatingFibonacciHeap{}, NilError("One of the heaps to merge is nil. Cannot merge") + return FloatingFibonacciHeap{}, NilError("one of the heaps to merge is nil. Cannot merge") } resultSize := heap.size + other.size diff --git a/fibheap/fibheap_test.go b/fibheap/fibheap_test.go index b54544b..8092275 100644 --- a/fibheap/fibheap_test.go +++ b/fibheap/fibheap_test.go @@ -164,12 +164,12 @@ func TestFibHeap_Min_EmptyHeap(t *testing.T) { heap := NewFloatFibHeap() heap.Enqueue(0) - min, err := heap.DequeueMin() + _, err := heap.DequeueMin() require.NoError(t, err) // Heap should be empty at this point - min, err = heap.Min() + min, err := heap.Min() assert.EqualError(t, err, "Trying to get minimum element of empty heap") assert.Nil(t, min) @@ -228,7 +228,7 @@ func TestFibHeap_DecreaseKey_EmptyHeap(t *testing.T) { min, err := heap.DecreaseKey(elem, 0) assert.IsType(t, EmptyHeapError(""), err) - assert.EqualError(t, err, "Cannot decrease key in an empty heap") + assert.EqualError(t, err, "cannot decrease key in an empty heap") assert.Nil(t, min) } @@ -238,7 +238,7 @@ func TestFibHeap_DecreaseKey_NilNode(t *testing.T) { min, err := heap.DecreaseKey(nil, 0) assert.IsType(t, NilError(""), err) - assert.EqualError(t, err, "Cannot decrease key: given node is nil") + assert.EqualError(t, err, "cannot decrease key: given node is nil") assert.Nil(t, min) } @@ -247,7 +247,7 @@ func TestFibHeap_DecreaseKey_LargerNewPriority(t *testing.T) { node := heap.Enqueue(1) min, err := heap.DecreaseKey(node, 20) - assert.EqualError(t, err, "The given new priority: 20, is larger than or equal to the old: 1") + assert.EqualError(t, err, "the given new priority: 20, is larger than or equal to the old: 1") assert.Nil(t, min) } @@ -296,7 +296,7 @@ func TestFibHeap_Delete_EmptyHeap(t *testing.T) { // Heap should be empty at this point err := heap.Delete(elem) assert.IsType(t, EmptyHeapError(""), err) - assert.EqualError(t, err, "Cannot delete element from an empty heap") + assert.EqualError(t, err, "cannot delete element from an empty heap") } func TestFibHeap_Delete_NilNode(t *testing.T) { @@ -304,7 +304,7 @@ func TestFibHeap_Delete_NilNode(t *testing.T) { heap.Enqueue(1) err := heap.Delete(nil) assert.IsType(t, NilError(""), err) - assert.EqualError(t, err, "Cannot delete node: given node is nil") + assert.EqualError(t, err, "cannot delete node: given node is nil") } func TestMerge(t *testing.T) { @@ -330,11 +330,10 @@ func TestMerge(t *testing.T) { } func TestFibHeap_Merge_NilHeap(t *testing.T) { - var heap FloatingFibonacciHeap - heap = NewFloatFibHeap() + heap := NewFloatFibHeap() newHeap, err := heap.Merge(nil) assert.IsType(t, NilError(""), err) - assert.EqualError(t, err, "One of the heaps to merge is nil. Cannot merge") + assert.EqualError(t, err, "one of the heaps to merge is nil. Cannot merge") assert.Equal(t, newHeap, FloatingFibonacciHeap{}) } diff --git a/graph/simple.go b/graph/simple.go index b01a1e3..92af1af 100644 --- a/graph/simple.go +++ b/graph/simple.go @@ -118,9 +118,9 @@ func (g *SimpleGraph) Degree(v interface{}) (int, error) { } func (g *SimpleGraph) addVertex(v interface{}) { - mm, ok := g.adjacencyList[v] + _, ok := g.adjacencyList[v] if !ok { - mm = make(map[interface{}]struct{}) + mm := make(map[interface{}]struct{}) g.adjacencyList[v] = mm g.v++ } diff --git a/hashmap/fastinteger/hashmap_test.go b/hashmap/fastinteger/hashmap_test.go index 4a2c10e..f14db1d 100644 --- a/hashmap/fastinteger/hashmap_test.go +++ b/hashmap/fastinteger/hashmap_test.go @@ -197,16 +197,11 @@ func BenchmarkGoMapExists(b *testing.B) { b.ResetTimer() - var ok bool for i := 0; i < b.N; i++ { - for _, key := range keys { - _, ok = hm[key] // or the compiler complains - } + for range keys { } } b.StopTimer() - if ok { // or the compiler complains - } } func BenchmarkDelete(b *testing.B) { diff --git a/list/persistent.go b/list/persistent.go index 5ca23e5..8d01755 100644 --- a/list/persistent.go +++ b/list/persistent.go @@ -28,7 +28,7 @@ var ( // ErrEmptyList is returned when an invalid operation is performed on an // empty list. - ErrEmptyList = errors.New("Empty list") + ErrEmptyList = errors.New("empty list") ) // PersistentList is an immutable, persistent linked list. diff --git a/rangetree/immutable.go b/rangetree/immutable.go index 89b42fa..df038e5 100644 --- a/rangetree/immutable.go +++ b/rangetree/immutable.go @@ -203,19 +203,11 @@ func (irt *immutableRangeTree) apply(list orderedNodes, interval Interval, low, high := interval.LowAtDimension(dimension), interval.HighAtDimension(dimension) if isLastDimension(irt.dimensions, dimension) { - if !list.apply(low, high, fn) { - return false - } + return list.apply(low, high, fn) } else { - if !list.apply(low, high, func(n *node) bool { - if !irt.apply(n.orderedNodes, interval, dimension+1, fn) { - return false - } - return true - }) { - return false - } - return true + return list.apply(low, high, func(n *node) bool { + return irt.apply(n.orderedNodes, interval, dimension+1, fn) + }) } return true diff --git a/rangetree/orderedtree.go b/rangetree/orderedtree.go index 09a47b4..af2bfbd 100644 --- a/rangetree/orderedtree.go +++ b/rangetree/orderedtree.go @@ -183,19 +183,11 @@ func (ot *orderedTree) apply(list orderedNodes, interval Interval, low, high := interval.LowAtDimension(dimension), interval.HighAtDimension(dimension) if isLastDimension(ot.dimensions, dimension) { - if !list.apply(low, high, fn) { - return false - } + return list.apply(low, high, fn) } else { - if !list.apply(low, high, func(n *node) bool { - if !ot.apply(n.orderedNodes, interval, dimension+1, fn) { - return false - } - return true - }) { - return false - } - return true + return list.apply(low, high, func(n *node) bool { + return ot.apply(n.orderedNodes, interval, dimension+1, fn) + }) } return true diff --git a/rtree/hilbert/action.go b/rtree/hilbert/action.go index 608a26b..bc8ddb0 100644 --- a/rtree/hilbert/action.go +++ b/rtree/hilbert/action.go @@ -53,9 +53,7 @@ func (ga *getAction) keys() hilberts { return nil } -func (ga *getAction) addNode(i int64, n *node) { - return // not necessary for gets -} +func (ga *getAction) addNode(i int64, n *node) {} func (ga *getAction) nodes() []*node { return nil diff --git a/slice/skip/iterator.go b/slice/skip/iterator.go index bd44ac2..32cd43a 100644 --- a/slice/skip/iterator.go +++ b/slice/skip/iterator.go @@ -18,8 +18,6 @@ package skip import "github.com/Workiva/go-datastructures/common" -const iteratorExhausted = -2 - // iterator represents an object that can be iterated. It will // return false on Next and nil on Value if there are no further // values to be iterated. diff --git a/trie/ctrie/ctrie.go b/trie/ctrie/ctrie.go index fed475d..acfba62 100644 --- a/trie/ctrie/ctrie.go +++ b/trie/ctrie/ctrie.go @@ -376,7 +376,7 @@ func (c *Ctrie) Size() uint { // computation is amortized across the update operations that occurred // since the last snapshot. size := uint(0) - for _ = range c.Iterator(nil) { + for range c.Iterator(nil) { size++ } return size @@ -482,20 +482,18 @@ func (c *Ctrie) iinsert(i *iNode, entry *Entry, lev uint, parent *iNode, startGe // If the relevant bit is present in the bitmap, then its corresponding // branch is read from the array. branch := cn.array[pos] - switch branch.(type) { + switch b := branch.(type) { case *iNode: // If the branch is an I-node, then iinsert is called recursively. - in := branch.(*iNode) - if startGen == in.gen { - return c.iinsert(in, entry, lev+w, i, startGen) + if startGen == b.gen { + return c.iinsert(b, entry, lev+w, i, startGen) } if gcas(i, main, &mainNode{cNode: cn.renewed(startGen, c)}, c) { return c.iinsert(i, entry, lev, parent, startGen) } return false case *sNode: - sn := branch.(*sNode) - if !bytes.Equal(sn.Key, entry.Key) { + if !bytes.Equal(b.Key, entry.Key) { // If the branch is an S-node and its key is not equal to the // key being inserted, then the Ctrie has to be extended with // an additional level. The C-node is replaced with its updated @@ -508,7 +506,7 @@ func (c *Ctrie) iinsert(i *iNode, entry *Entry, lev uint, parent *iNode, startGe rn = cn.renewed(i.gen, c) } nsn := &sNode{entry} - nin := &iNode{main: newMainNode(sn, sn.hash, nsn, nsn.hash, lev+w, i.gen), gen: i.gen} + nin := &iNode{main: newMainNode(b, b.hash, nsn, nsn.hash, lev+w, i.gen), gen: i.gen} ncn := &mainNode{cNode: rn.updated(pos, nin, i.gen)} return gcas(i, main, ncn, c) } @@ -549,13 +547,12 @@ func (c *Ctrie) ilookup(i *iNode, entry *Entry, lev uint, parent *iNode, startGe } // Otherwise, the relevant branch at index pos is read from the array. branch := cn.array[pos] - switch branch.(type) { + switch b := branch.(type) { case *iNode: // If the branch is an I-node, the ilookup procedure is called // recursively at the next level. - in := branch.(*iNode) - if c.readOnly || startGen == in.gen { - return c.ilookup(in, entry, lev+w, i, startGen) + if c.readOnly || startGen == b.gen { + return c.ilookup(b, entry, lev+w, i, startGen) } if gcas(i, main, &mainNode{cNode: cn.renewed(startGen, c)}, c) { return c.ilookup(i, entry, lev, parent, startGen) @@ -567,9 +564,8 @@ func (c *Ctrie) ilookup(i *iNode, entry *Entry, lev uint, parent *iNode, startGe // same hashcode prefixes, but they need not be equal. If they are // equal, the corresponding value from the S-node is // returned and a NOTFOUND value otherwise. - sn := branch.(*sNode) - if bytes.Equal(sn.Key, entry.Key) { - return sn.Value, true, true + if bytes.Equal(b.Key, entry.Key) { + return b.Value, true, true } return nil, false, true default: @@ -605,13 +601,12 @@ func (c *Ctrie) iremove(i *iNode, entry *Entry, lev uint, parent *iNode, startGe } // Otherwise, the relevant branch at index pos is read from the array. branch := cn.array[pos] - switch branch.(type) { + switch b := branch.(type) { case *iNode: // If the branch is an I-node, the iremove procedure is called // recursively at the next level. - in := branch.(*iNode) - if startGen == in.gen { - return c.iremove(in, entry, lev+w, i, startGen) + if startGen == b.gen { + return c.iremove(b, entry, lev+w, i, startGen) } if gcas(i, main, &mainNode{cNode: cn.renewed(startGen, c)}, c) { return c.iremove(i, entry, lev, parent, startGen) @@ -620,8 +615,7 @@ func (c *Ctrie) iremove(i *iNode, entry *Entry, lev uint, parent *iNode, startGe case *sNode: // If the branch is an S-node, its key is compared against the key // being removed. - sn := branch.(*sNode) - if !bytes.Equal(sn.Key, entry.Key) { + if !bytes.Equal(b.Key, entry.Key) { // If the keys are not equal, the NOTFOUND value is returned. return nil, false, true } @@ -640,7 +634,7 @@ func (c *Ctrie) iremove(i *iNode, entry *Entry, lev uint, parent *iNode, startGe cleanParent(parent, i, entry.hash, lev-w, c, startGen) } } - return sn.Value, true, true + return b.Value, true, true } return nil, false, false default: @@ -671,9 +665,9 @@ func (c *Ctrie) iremove(i *iNode, entry *Entry, lev uint, parent *iNode, startGe func toContracted(cn *cNode, lev uint) *mainNode { if lev > 0 && len(cn.array) == 1 { branch := cn.array[0] - switch branch.(type) { + switch b := branch.(type) { case *sNode: - return entomb(branch.(*sNode)) + return entomb(b) default: return &mainNode{cNode: cn} } @@ -685,12 +679,11 @@ func toContracted(cn *cNode, lev uint) *mainNode { func toCompressed(cn *cNode, lev uint) *mainNode { tmpArray := make([]branch, len(cn.array)) for i, sub := range cn.array { - switch sub.(type) { + switch s := sub.(type) { case *iNode: - inode := sub.(*iNode) - mainPtr := (*unsafe.Pointer)(unsafe.Pointer(&inode.main)) + mainPtr := (*unsafe.Pointer)(unsafe.Pointer(&s.main)) main := (*mainNode)(atomic.LoadPointer(mainPtr)) - tmpArray[i] = resurrect(inode, main) + tmpArray[i] = resurrect(s, main) case *sNode: tmpArray[i] = sub default: diff --git a/trie/ctrie/ctrie_test.go b/trie/ctrie/ctrie_test.go index e4dd4a2..55a3adb 100644 --- a/trie/ctrie/ctrie_test.go +++ b/trie/ctrie/ctrie_test.go @@ -381,7 +381,7 @@ func TestIterator(t *testing.T) { close(cancel) // Drain anything already put on the channel. Since select chooses a // pseudo-random case, we must attempt to drain for every item. - for _ = range expected { + for range expected { <-iter } _, ok = <-iter diff --git a/trie/dtrie/dtrie.go b/trie/dtrie/dtrie.go index 4608de3..fb753cf 100644 --- a/trie/dtrie/dtrie.go +++ b/trie/dtrie/dtrie.go @@ -71,7 +71,7 @@ func New(hasher func(v interface{}) uint32) *Dtrie { // Size returns the number of entries in the Dtrie. func (d *Dtrie) Size() (size int) { - for _ = range iterate(d.root, nil) { + for range iterate(d.root, nil) { size++ } return size diff --git a/trie/dtrie/dtrie_test.go b/trie/dtrie/dtrie_test.go index 1ff042a..f404aea 100644 --- a/trie/dtrie/dtrie_test.go +++ b/trie/dtrie/dtrie_test.go @@ -102,7 +102,7 @@ func TestIterate(t *testing.T) { n := insertTest(t, defaultHasher, 10000) echan := iterate(n, nil) c := 0 - for _ = range echan { + for range echan { c++ } assert.Equal(t, 10000, c) @@ -110,7 +110,7 @@ func TestIterate(t *testing.T) { c = 0 stop := make(chan struct{}) echan = iterate(n, stop) - for _ = range echan { + for range echan { c++ if c == 100 { close(stop) @@ -122,7 +122,7 @@ func TestIterate(t *testing.T) { n = insertTest(t, collisionHash, 1000) c = 0 echan = iterate(n, nil) - for _ = range echan { + for range echan { c++ } assert.Equal(t, 1000, c)