From 95c3aa7bfb1cfb8e1fbcae941a55248a383cfb8c Mon Sep 17 00:00:00 2001 From: Jason Playne Date: Sat, 11 Nov 2023 12:01:13 +0800 Subject: [PATCH] fixup linter suggestions --- lib/dedupe/forgetfulmap/map.go | 9 ++++----- lib/dedupe/forgetfulmap/map_test.go | 14 +++++++------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/lib/dedupe/forgetfulmap/map.go b/lib/dedupe/forgetfulmap/map.go index 51d0873e..ba53ba93 100644 --- a/lib/dedupe/forgetfulmap/map.go +++ b/lib/dedupe/forgetfulmap/map.go @@ -159,12 +159,12 @@ func (f *ForgetfulSyncMap) AddKey(key interface{}) { return } if kb, ok := key.([]byte); ok { - if 0 == len(kb) { + if len(kb) == 0 { return } } if ks, ok := key.(string); ok { - if "" == ks { + if ks == "" { return } } @@ -172,7 +172,7 @@ func (f *ForgetfulSyncMap) AddKey(key interface{}) { } func (f *ForgetfulSyncMap) AddKeyStr(key string) { // avoid storing empty things - if "" == key { + if key == "" { return } f.Store(key, nil) @@ -188,9 +188,8 @@ func (f *ForgetfulSyncMap) Load(key any) (any, bool) { return t.value, retBool } return nil, false - } else { - return retVal, retBool } + return retVal, retBool } // Store remembers an item diff --git a/lib/dedupe/forgetfulmap/map_test.go b/lib/dedupe/forgetfulmap/map_test.go index 4f6fa0a6..b100cbf4 100644 --- a/lib/dedupe/forgetfulmap/map_test.go +++ b/lib/dedupe/forgetfulmap/map_test.go @@ -104,7 +104,7 @@ func TestForgetfulSyncMap_DontSweepNewPlane(t *testing.T) { t.Error("Test plane not added.") } - //this shouldn't sweep our new plane. + // this shouldn't sweep our new plane. testMap.sweep() if testMap.Len() != 1 { @@ -212,7 +212,7 @@ func TestForgetfulSyncMap_Range(t *testing.T) { item := testItem{value: "item 222"} testMap.Store("test", item) - if 1 != testMap.Len() { + if testMap.Len() != 1 { t.Error("Failed to store test item") } @@ -226,7 +226,7 @@ func TestForgetfulSyncMap_Range(t *testing.T) { if !tOk { t.Error("Failed to get our test item out unmolested") } - if "item 222" != typedLoadedItem.value { + if typedLoadedItem.value != "item 222" { t.Errorf("item came out changed?! - %+v", item) } @@ -237,14 +237,14 @@ func TestForgetfulSyncMap_Range(t *testing.T) { if !tOk { t.Error("Failed to get our test item out unmolested") } - if "item 222" != typedLoadedItem.value { + if typedLoadedItem.value != "item 222" { t.Errorf("item came out changed?! - %+v", item) } return true }) - if 1 != counter { + if counter != 1 { t.Error("Failed to range correctly through the map") } } @@ -268,12 +268,12 @@ func TestForgetfulSyncMap_SweepWithCustomExpiryFunc(t *testing.T) { item2 := testItem{value: "item 222", remove: true} testMap.Store("item2", item2) - if 2 != testMap.Len() { + if testMap.Len() != 2 { t.Error("Failed to store test items") } testMap.sweep() - if 1 != testMap.Len() { + if testMap.Len() != 1 { t.Error("Failed to remove our test2 item on sweep") }