From 0164d6f2af3b4143b7ca4787e4d2b1d5b571f554 Mon Sep 17 00:00:00 2001 From: Sourcegraph Date: Wed, 8 Feb 2023 08:55:30 +0000 Subject: [PATCH] Replacing fmt.Sprintf with strconv.Iota --- containers/containers_test.go | 3 ++- examples/avltree/avltree.go | 1 + examples/btree/btree.go | 1 + examples/customcomparator/customcomparator.go | 1 + examples/enumerablewithindex/enumerablewithindex.go | 1 + examples/enumerablewithkey/enumerablewithkey.go | 1 + examples/iteratorwithindex/iteratorwithindex.go | 3 ++- examples/iteratorwithkey/iteratorwithkey.go | 3 ++- examples/redblacktree/redblacktree.go | 1 + examples/redblacktreeextended/redblacktreeextended.go | 1 + examples/serialization/serialization.go | 1 + lists/arraylist/arraylist_test.go | 3 ++- lists/arraylist/serialization.go | 1 + lists/doublylinkedlist/serialization.go | 1 + lists/singlylinkedlist/serialization.go | 1 + maps/hashbidimap/hashbidimap.go | 1 + maps/hashbidimap/serialization.go | 1 + maps/hashmap/hashmap.go | 1 + maps/hashmap/serialization.go | 1 + maps/linkedhashmap/linkedhashmap.go | 3 ++- maps/linkedhashmap/serialization.go | 1 + maps/treebidimap/serialization.go | 1 + maps/treebidimap/treebidimap.go | 3 ++- maps/treebidimap/treebidimap_test.go | 3 ++- maps/treemap/treemap.go | 3 ++- maps/treemap/treemap_test.go | 3 ++- queues/circularbuffer/serialization.go | 1 + queues/priorityqueue/priorityqueue.go | 3 ++- queues/priorityqueue/priorityqueue_test.go | 3 ++- sets/hashset/hashset.go | 3 ++- sets/hashset/serialization.go | 1 + sets/linkedhashset/linkedhashset.go | 3 ++- sets/linkedhashset/serialization.go | 1 + sets/treeset/serialization.go | 1 + sets/treeset/treeset.go | 5 +++-- stacks/arraystack/arraystack.go | 3 ++- stacks/linkedliststack/linkedliststack.go | 3 ++- trees/avltree/avltree.go | 1 + trees/avltree/avltree_test.go | 8 +++++--- trees/avltree/serialization.go | 1 + trees/binaryheap/binaryheap.go | 3 ++- trees/btree/btree.go | 3 ++- trees/btree/serialization.go | 1 + trees/redblacktree/redblacktree.go | 1 + trees/redblacktree/redblacktree_test.go | 8 +++++--- trees/redblacktree/serialization.go | 1 + 46 files changed, 73 insertions(+), 25 deletions(-) diff --git a/containers/containers_test.go b/containers/containers_test.go index e92d123..f7c5572 100644 --- a/containers/containers_test.go +++ b/containers/containers_test.go @@ -8,9 +8,10 @@ package containers import ( "fmt" - "github.com/emirpasic/gods/utils" "strings" "testing" + + "github.com/emirpasic/gods/utils" ) // For testing purposes diff --git a/examples/avltree/avltree.go b/examples/avltree/avltree.go index b6d1aab..659b216 100644 --- a/examples/avltree/avltree.go +++ b/examples/avltree/avltree.go @@ -6,6 +6,7 @@ package main import ( "fmt" + avl "github.com/emirpasic/gods/trees/avltree" ) diff --git a/examples/btree/btree.go b/examples/btree/btree.go index ea61b03..9aecb57 100644 --- a/examples/btree/btree.go +++ b/examples/btree/btree.go @@ -6,6 +6,7 @@ package main import ( "fmt" + "github.com/emirpasic/gods/trees/btree" ) diff --git a/examples/customcomparator/customcomparator.go b/examples/customcomparator/customcomparator.go index b61d969..9d8514d 100644 --- a/examples/customcomparator/customcomparator.go +++ b/examples/customcomparator/customcomparator.go @@ -6,6 +6,7 @@ package main import ( "fmt" + "github.com/emirpasic/gods/sets/treeset" ) diff --git a/examples/enumerablewithindex/enumerablewithindex.go b/examples/enumerablewithindex/enumerablewithindex.go index 9545911..4a256f1 100644 --- a/examples/enumerablewithindex/enumerablewithindex.go +++ b/examples/enumerablewithindex/enumerablewithindex.go @@ -6,6 +6,7 @@ package main import ( "fmt" + "github.com/emirpasic/gods/sets/treeset" ) diff --git a/examples/enumerablewithkey/enumerablewithkey.go b/examples/enumerablewithkey/enumerablewithkey.go index 7f05040..fd56eee 100644 --- a/examples/enumerablewithkey/enumerablewithkey.go +++ b/examples/enumerablewithkey/enumerablewithkey.go @@ -6,6 +6,7 @@ package main import ( "fmt" + "github.com/emirpasic/gods/maps/treemap" ) diff --git a/examples/iteratorwithindex/iteratorwithindex.go b/examples/iteratorwithindex/iteratorwithindex.go index 4cbc87e..baef38a 100644 --- a/examples/iteratorwithindex/iteratorwithindex.go +++ b/examples/iteratorwithindex/iteratorwithindex.go @@ -6,8 +6,9 @@ package main import ( "fmt" - "github.com/emirpasic/gods/sets/treeset" "strings" + + "github.com/emirpasic/gods/sets/treeset" ) // IteratorWithIndexExample to demonstrate basic usage of IteratorWithIndex diff --git a/examples/iteratorwithkey/iteratorwithkey.go b/examples/iteratorwithkey/iteratorwithkey.go index 521e43b..88f647f 100644 --- a/examples/iteratorwithkey/iteratorwithkey.go +++ b/examples/iteratorwithkey/iteratorwithkey.go @@ -6,8 +6,9 @@ package main import ( "fmt" - "github.com/emirpasic/gods/maps/treemap" "strings" + + "github.com/emirpasic/gods/maps/treemap" ) // IteratorWithKeyExample to demonstrate basic usage of IteratorWithKey diff --git a/examples/redblacktree/redblacktree.go b/examples/redblacktree/redblacktree.go index b7d9803..df87695 100644 --- a/examples/redblacktree/redblacktree.go +++ b/examples/redblacktree/redblacktree.go @@ -6,6 +6,7 @@ package main import ( "fmt" + rbt "github.com/emirpasic/gods/trees/redblacktree" ) diff --git a/examples/redblacktreeextended/redblacktreeextended.go b/examples/redblacktreeextended/redblacktreeextended.go index 6e90129..d074a6f 100644 --- a/examples/redblacktreeextended/redblacktreeextended.go +++ b/examples/redblacktreeextended/redblacktreeextended.go @@ -6,6 +6,7 @@ package redblacktreeextended import ( "fmt" + rbt "github.com/emirpasic/gods/trees/redblacktree" ) diff --git a/examples/serialization/serialization.go b/examples/serialization/serialization.go index 2f94c5e..4536307 100644 --- a/examples/serialization/serialization.go +++ b/examples/serialization/serialization.go @@ -2,6 +2,7 @@ package serialization import ( "fmt" + "github.com/emirpasic/gods/lists/arraylist" "github.com/emirpasic/gods/maps/hashmap" ) diff --git a/lists/arraylist/arraylist_test.go b/lists/arraylist/arraylist_test.go index 3b7c8d7..7b1b98f 100644 --- a/lists/arraylist/arraylist_test.go +++ b/lists/arraylist/arraylist_test.go @@ -7,9 +7,10 @@ package arraylist import ( "encoding/json" "fmt" - "github.com/emirpasic/gods/utils" "strings" "testing" + + "github.com/emirpasic/gods/utils" ) func TestListNew(t *testing.T) { diff --git a/lists/arraylist/serialization.go b/lists/arraylist/serialization.go index 5e86fe9..00cfcd8 100644 --- a/lists/arraylist/serialization.go +++ b/lists/arraylist/serialization.go @@ -6,6 +6,7 @@ package arraylist import ( "encoding/json" + "github.com/emirpasic/gods/containers" ) diff --git a/lists/doublylinkedlist/serialization.go b/lists/doublylinkedlist/serialization.go index f210f9a..b716856 100644 --- a/lists/doublylinkedlist/serialization.go +++ b/lists/doublylinkedlist/serialization.go @@ -6,6 +6,7 @@ package doublylinkedlist import ( "encoding/json" + "github.com/emirpasic/gods/containers" ) diff --git a/lists/singlylinkedlist/serialization.go b/lists/singlylinkedlist/serialization.go index 588a316..8bdd5ff 100644 --- a/lists/singlylinkedlist/serialization.go +++ b/lists/singlylinkedlist/serialization.go @@ -6,6 +6,7 @@ package singlylinkedlist import ( "encoding/json" + "github.com/emirpasic/gods/containers" ) diff --git a/maps/hashbidimap/hashbidimap.go b/maps/hashbidimap/hashbidimap.go index 5a386ec..fb1b3f9 100644 --- a/maps/hashbidimap/hashbidimap.go +++ b/maps/hashbidimap/hashbidimap.go @@ -17,6 +17,7 @@ package hashbidimap import ( "fmt" + "github.com/emirpasic/gods/maps" "github.com/emirpasic/gods/maps/hashmap" ) diff --git a/maps/hashbidimap/serialization.go b/maps/hashbidimap/serialization.go index dfae043..dcc730b 100644 --- a/maps/hashbidimap/serialization.go +++ b/maps/hashbidimap/serialization.go @@ -6,6 +6,7 @@ package hashbidimap import ( "encoding/json" + "github.com/emirpasic/gods/containers" ) diff --git a/maps/hashmap/hashmap.go b/maps/hashmap/hashmap.go index e945c39..25838db 100644 --- a/maps/hashmap/hashmap.go +++ b/maps/hashmap/hashmap.go @@ -13,6 +13,7 @@ package hashmap import ( "fmt" + "github.com/emirpasic/gods/maps" ) diff --git a/maps/hashmap/serialization.go b/maps/hashmap/serialization.go index a86fd86..60038b7 100644 --- a/maps/hashmap/serialization.go +++ b/maps/hashmap/serialization.go @@ -6,6 +6,7 @@ package hashmap import ( "encoding/json" + "github.com/emirpasic/gods/containers" "github.com/emirpasic/gods/utils" ) diff --git a/maps/linkedhashmap/linkedhashmap.go b/maps/linkedhashmap/linkedhashmap.go index d625b3d..7cf2012 100644 --- a/maps/linkedhashmap/linkedhashmap.go +++ b/maps/linkedhashmap/linkedhashmap.go @@ -13,9 +13,10 @@ package linkedhashmap import ( "fmt" + "strings" + "github.com/emirpasic/gods/lists/doublylinkedlist" "github.com/emirpasic/gods/maps" - "strings" ) // Assert Map implementation diff --git a/maps/linkedhashmap/serialization.go b/maps/linkedhashmap/serialization.go index 9265f1d..7f80479 100644 --- a/maps/linkedhashmap/serialization.go +++ b/maps/linkedhashmap/serialization.go @@ -7,6 +7,7 @@ package linkedhashmap import ( "bytes" "encoding/json" + "github.com/emirpasic/gods/containers" "github.com/emirpasic/gods/utils" ) diff --git a/maps/treebidimap/serialization.go b/maps/treebidimap/serialization.go index 2cccce6..69e9fd3 100644 --- a/maps/treebidimap/serialization.go +++ b/maps/treebidimap/serialization.go @@ -6,6 +6,7 @@ package treebidimap import ( "encoding/json" + "github.com/emirpasic/gods/containers" "github.com/emirpasic/gods/utils" ) diff --git a/maps/treebidimap/treebidimap.go b/maps/treebidimap/treebidimap.go index 37af07e..e5d4f4d 100644 --- a/maps/treebidimap/treebidimap.go +++ b/maps/treebidimap/treebidimap.go @@ -19,10 +19,11 @@ package treebidimap import ( "fmt" + "strings" + "github.com/emirpasic/gods/maps" "github.com/emirpasic/gods/trees/redblacktree" "github.com/emirpasic/gods/utils" - "strings" ) // Assert Map implementation diff --git a/maps/treebidimap/treebidimap_test.go b/maps/treebidimap/treebidimap_test.go index 75296e8..bd468a6 100644 --- a/maps/treebidimap/treebidimap_test.go +++ b/maps/treebidimap/treebidimap_test.go @@ -7,9 +7,10 @@ package treebidimap import ( "encoding/json" "fmt" - "github.com/emirpasic/gods/utils" "strings" "testing" + + "github.com/emirpasic/gods/utils" ) func TestMapPut(t *testing.T) { diff --git a/maps/treemap/treemap.go b/maps/treemap/treemap.go index a77d16d..bf1e1c4 100644 --- a/maps/treemap/treemap.go +++ b/maps/treemap/treemap.go @@ -13,10 +13,11 @@ package treemap import ( "fmt" + "strings" + "github.com/emirpasic/gods/maps" rbt "github.com/emirpasic/gods/trees/redblacktree" "github.com/emirpasic/gods/utils" - "strings" ) // Assert Map implementation diff --git a/maps/treemap/treemap_test.go b/maps/treemap/treemap_test.go index f0c96ba..ea44041 100644 --- a/maps/treemap/treemap_test.go +++ b/maps/treemap/treemap_test.go @@ -7,9 +7,10 @@ package treemap import ( "encoding/json" "fmt" - "github.com/emirpasic/gods/utils" "strings" "testing" + + "github.com/emirpasic/gods/utils" ) func TestMapPut(t *testing.T) { diff --git a/queues/circularbuffer/serialization.go b/queues/circularbuffer/serialization.go index da2543d..96d2736 100644 --- a/queues/circularbuffer/serialization.go +++ b/queues/circularbuffer/serialization.go @@ -6,6 +6,7 @@ package circularbuffer import ( "encoding/json" + "github.com/emirpasic/gods/containers" ) diff --git a/queues/priorityqueue/priorityqueue.go b/queues/priorityqueue/priorityqueue.go index 3a7e6f2..da98e3f 100644 --- a/queues/priorityqueue/priorityqueue.go +++ b/queues/priorityqueue/priorityqueue.go @@ -17,10 +17,11 @@ package priorityqueue import ( "fmt" + "strings" + "github.com/emirpasic/gods/queues" "github.com/emirpasic/gods/trees/binaryheap" "github.com/emirpasic/gods/utils" - "strings" ) // Assert Queue implementation diff --git a/queues/priorityqueue/priorityqueue_test.go b/queues/priorityqueue/priorityqueue_test.go index 1036fdb..1251824 100644 --- a/queues/priorityqueue/priorityqueue_test.go +++ b/queues/priorityqueue/priorityqueue_test.go @@ -7,10 +7,11 @@ package priorityqueue import ( "encoding/json" "fmt" - "github.com/emirpasic/gods/utils" "math/rand" "strings" "testing" + + "github.com/emirpasic/gods/utils" ) type Element struct { diff --git a/sets/hashset/hashset.go b/sets/hashset/hashset.go index 9439928..fdda6de 100644 --- a/sets/hashset/hashset.go +++ b/sets/hashset/hashset.go @@ -11,8 +11,9 @@ package hashset import ( "fmt" - "github.com/emirpasic/gods/sets" "strings" + + "github.com/emirpasic/gods/sets" ) // Assert Set implementation diff --git a/sets/hashset/serialization.go b/sets/hashset/serialization.go index 583d129..13e78d8 100644 --- a/sets/hashset/serialization.go +++ b/sets/hashset/serialization.go @@ -6,6 +6,7 @@ package hashset import ( "encoding/json" + "github.com/emirpasic/gods/containers" ) diff --git a/sets/linkedhashset/linkedhashset.go b/sets/linkedhashset/linkedhashset.go index 3bf4e5f..a46b186 100644 --- a/sets/linkedhashset/linkedhashset.go +++ b/sets/linkedhashset/linkedhashset.go @@ -15,9 +15,10 @@ package linkedhashset import ( "fmt" + "strings" + "github.com/emirpasic/gods/lists/doublylinkedlist" "github.com/emirpasic/gods/sets" - "strings" ) // Assert Set implementation diff --git a/sets/linkedhashset/serialization.go b/sets/linkedhashset/serialization.go index ab2f3b4..810fa5b 100644 --- a/sets/linkedhashset/serialization.go +++ b/sets/linkedhashset/serialization.go @@ -6,6 +6,7 @@ package linkedhashset import ( "encoding/json" + "github.com/emirpasic/gods/containers" ) diff --git a/sets/treeset/serialization.go b/sets/treeset/serialization.go index 76d049d..7ebec6b 100644 --- a/sets/treeset/serialization.go +++ b/sets/treeset/serialization.go @@ -6,6 +6,7 @@ package treeset import ( "encoding/json" + "github.com/emirpasic/gods/containers" ) diff --git a/sets/treeset/treeset.go b/sets/treeset/treeset.go index 3507cc9..ab033c2 100644 --- a/sets/treeset/treeset.go +++ b/sets/treeset/treeset.go @@ -11,11 +11,12 @@ package treeset import ( "fmt" + "reflect" + "strings" + "github.com/emirpasic/gods/sets" rbt "github.com/emirpasic/gods/trees/redblacktree" "github.com/emirpasic/gods/utils" - "reflect" - "strings" ) // Assert Set implementation diff --git a/stacks/arraystack/arraystack.go b/stacks/arraystack/arraystack.go index 78c3dda..1c7a608 100644 --- a/stacks/arraystack/arraystack.go +++ b/stacks/arraystack/arraystack.go @@ -11,9 +11,10 @@ package arraystack import ( "fmt" + "strings" + "github.com/emirpasic/gods/lists/arraylist" "github.com/emirpasic/gods/stacks" - "strings" ) // Assert Stack implementation diff --git a/stacks/linkedliststack/linkedliststack.go b/stacks/linkedliststack/linkedliststack.go index ce69b21..cd6e688 100644 --- a/stacks/linkedliststack/linkedliststack.go +++ b/stacks/linkedliststack/linkedliststack.go @@ -11,9 +11,10 @@ package linkedliststack import ( "fmt" + "strings" + "github.com/emirpasic/gods/lists/singlylinkedlist" "github.com/emirpasic/gods/stacks" - "strings" ) // Assert Stack implementation diff --git a/trees/avltree/avltree.go b/trees/avltree/avltree.go index 128d313..77fbda5 100644 --- a/trees/avltree/avltree.go +++ b/trees/avltree/avltree.go @@ -11,6 +11,7 @@ package avltree import ( "fmt" + "github.com/emirpasic/gods/trees" "github.com/emirpasic/gods/utils" ) diff --git a/trees/avltree/avltree_test.go b/trees/avltree/avltree_test.go index 114b5a5..ac1c870 100644 --- a/trees/avltree/avltree_test.go +++ b/trees/avltree/avltree_test.go @@ -6,9 +6,11 @@ package avltree import ( "encoding/json" "fmt" - "github.com/emirpasic/gods/utils" + "strconv" "strings" "testing" + + "github.com/emirpasic/gods/utils" ) func TestAVLTreeGet(t *testing.T) { @@ -182,14 +184,14 @@ func TestAVLTreeLeftAndRight(t *testing.T) { tree.Put(1, "x") // overwrite tree.Put(2, "b") - if actualValue, expectedValue := fmt.Sprintf("%d", tree.Left().Key), "1"; actualValue != expectedValue { + if actualValue, expectedValue := strconv.Itoa(tree.Left().Key), "1"; actualValue != expectedValue { t.Errorf("Got %v expected %v", actualValue, expectedValue) } if actualValue, expectedValue := fmt.Sprintf("%s", tree.Left().Value), "x"; actualValue != expectedValue { t.Errorf("Got %v expected %v", actualValue, expectedValue) } - if actualValue, expectedValue := fmt.Sprintf("%d", tree.Right().Key), "7"; actualValue != expectedValue { + if actualValue, expectedValue := strconv.Itoa(tree.Right().Key), "7"; actualValue != expectedValue { t.Errorf("Got %v expected %v", actualValue, expectedValue) } if actualValue, expectedValue := fmt.Sprintf("%s", tree.Right().Value), "g"; actualValue != expectedValue { diff --git a/trees/avltree/serialization.go b/trees/avltree/serialization.go index 257c404..4e7a99f 100644 --- a/trees/avltree/serialization.go +++ b/trees/avltree/serialization.go @@ -6,6 +6,7 @@ package avltree import ( "encoding/json" + "github.com/emirpasic/gods/containers" "github.com/emirpasic/gods/utils" ) diff --git a/trees/binaryheap/binaryheap.go b/trees/binaryheap/binaryheap.go index e658f25..fce8d2b 100644 --- a/trees/binaryheap/binaryheap.go +++ b/trees/binaryheap/binaryheap.go @@ -13,10 +13,11 @@ package binaryheap import ( "fmt" + "strings" + "github.com/emirpasic/gods/lists/arraylist" "github.com/emirpasic/gods/trees" "github.com/emirpasic/gods/utils" - "strings" ) // Assert Tree implementation diff --git a/trees/btree/btree.go b/trees/btree/btree.go index eae4576..8328d01 100644 --- a/trees/btree/btree.go +++ b/trees/btree/btree.go @@ -19,9 +19,10 @@ package btree import ( "bytes" "fmt" + "strings" + "github.com/emirpasic/gods/trees" "github.com/emirpasic/gods/utils" - "strings" ) // Assert Tree implementation diff --git a/trees/btree/serialization.go b/trees/btree/serialization.go index 460f6e0..69922e7 100644 --- a/trees/btree/serialization.go +++ b/trees/btree/serialization.go @@ -6,6 +6,7 @@ package btree import ( "encoding/json" + "github.com/emirpasic/gods/containers" "github.com/emirpasic/gods/utils" ) diff --git a/trees/redblacktree/redblacktree.go b/trees/redblacktree/redblacktree.go index b335e3d..7dc3f29 100644 --- a/trees/redblacktree/redblacktree.go +++ b/trees/redblacktree/redblacktree.go @@ -13,6 +13,7 @@ package redblacktree import ( "fmt" + "github.com/emirpasic/gods/trees" "github.com/emirpasic/gods/utils" ) diff --git a/trees/redblacktree/redblacktree_test.go b/trees/redblacktree/redblacktree_test.go index 4c0f519..98bb55f 100644 --- a/trees/redblacktree/redblacktree_test.go +++ b/trees/redblacktree/redblacktree_test.go @@ -7,9 +7,11 @@ package redblacktree import ( "encoding/json" "fmt" - "github.com/emirpasic/gods/utils" + "strconv" "strings" "testing" + + "github.com/emirpasic/gods/utils" ) func TestRedBlackTreeGet(t *testing.T) { @@ -185,14 +187,14 @@ func TestRedBlackTreeLeftAndRight(t *testing.T) { tree.Put(1, "x") // overwrite tree.Put(2, "b") - if actualValue, expectedValue := fmt.Sprintf("%d", tree.Left().Key), "1"; actualValue != expectedValue { + if actualValue, expectedValue := strconv.Itoa(tree.Left().Key), "1"; actualValue != expectedValue { t.Errorf("Got %v expected %v", actualValue, expectedValue) } if actualValue, expectedValue := fmt.Sprintf("%s", tree.Left().Value), "x"; actualValue != expectedValue { t.Errorf("Got %v expected %v", actualValue, expectedValue) } - if actualValue, expectedValue := fmt.Sprintf("%d", tree.Right().Key), "7"; actualValue != expectedValue { + if actualValue, expectedValue := strconv.Itoa(tree.Right().Key), "7"; actualValue != expectedValue { t.Errorf("Got %v expected %v", actualValue, expectedValue) } if actualValue, expectedValue := fmt.Sprintf("%s", tree.Right().Value), "g"; actualValue != expectedValue { diff --git a/trees/redblacktree/serialization.go b/trees/redblacktree/serialization.go index 9f2a23c..929b785 100644 --- a/trees/redblacktree/serialization.go +++ b/trees/redblacktree/serialization.go @@ -6,6 +6,7 @@ package redblacktree import ( "encoding/json" + "github.com/emirpasic/gods/containers" "github.com/emirpasic/gods/utils" )