From d24994f8028b23e27d96bdd26b89ded5aea69746 Mon Sep 17 00:00:00 2001 From: Cesar Cejudo Date: Thu, 22 Aug 2024 10:58:18 -0600 Subject: [PATCH] lovely lint --- aesutil/aesutil_test.go | 10 +++++----- goutil/goutil.go | 2 +- ioutilx/copy_test.go | 2 +- jsonutil/jsonutil_test.go | 2 +- maputil/maputil_test.go | 2 +- ptrutil/ptr_test.go | 4 ++-- sliceutil/sliceutil_test.go | 24 ++++++++++++------------ syncutil/syncmap_test.go | 4 ++-- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/aesutil/aesutil_test.go b/aesutil/aesutil_test.go index 6b27408..fbea62f 100644 --- a/aesutil/aesutil_test.go +++ b/aesutil/aesutil_test.go @@ -18,13 +18,13 @@ func TestInvalidKeysAndData(t *testing.T) { data := []byte(testPlaintext) _, err := Encrypt("", data) if err == nil { - t.Errorf("Encrypt succeeded with an empty key") + t.Error("Encrypt succeeded with an empty key") } // Decrypt with empty key _, err = Decrypt("", testCiphertext) if err == nil { - t.Errorf("Decrypt succeeded with an empty key") + t.Error("Decrypt succeeded with an empty key") } // Decrypt with an incorrect key @@ -48,13 +48,13 @@ func TestInvalidKeysAndData(t *testing.T) { // Decrypt an short string (i.e. smaller than block size) _, err = Decrypt(testKeyString, "aaaabbbbcccc") if err == nil { - t.Errorf("Decrypt succeeded with an invalid key size") + t.Error("Decrypt succeeded with an invalid key size") } // Decrypt a non-base64 string _, err = Decrypt(testKeyString, fmt.Sprintf("%s#@?`", testCiphertext)) if err == nil { - t.Errorf("Decrypt succeeded with an invalid base64 string") + t.Error("Decrypt succeeded with an invalid base64 string") } } @@ -87,7 +87,7 @@ func TestEncryptAndDecrypt(t *testing.T) { t.Fatal("Decrypt failed, plaintext result is nil") } if string(plain) != testData { - t.Fatalf(diff.Cmp(testData, string(plain))) + t.Fatal(diff.Cmp(testData, string(plain))) } }) } diff --git a/goutil/goutil.go b/goutil/goutil.go index dc935b1..7d5d142 100644 --- a/goutil/goutil.go +++ b/goutil/goutil.go @@ -96,7 +96,7 @@ func ResolveWildcard(path string, mode build.ImportMode) ([]*build.Package, erro // Gather a list of directories with *.go files. goDirs := make(map[string]struct{}) - err = filepath.Walk(root.Dir, func(path string, info os.FileInfo, err error) error { + err = filepath.Walk(root.Dir, func(path string, info os.FileInfo, _ error) error { if !strings.HasSuffix(path, ".go") || info.IsDir() || strings.Contains(path, "/vendor/") { return nil } diff --git a/ioutilx/copy_test.go b/ioutilx/copy_test.go index 55b412c..c1ce84e 100644 --- a/ioutilx/copy_test.go +++ b/ioutilx/copy_test.go @@ -312,7 +312,7 @@ func TestCopyTree(t *testing.T) { err := CopyTree("test", "test_copytree", &CopyTreeOptions{ Symlinks: false, - Ignore: func(path string, fi []os.FileInfo) []string { + Ignore: func(_ string, _ []os.FileInfo) []string { return []string{"fifo"} }, CopyFunction: Copy, diff --git a/jsonutil/jsonutil_test.go b/jsonutil/jsonutil_test.go index 3e097ec..8bad34d 100644 --- a/jsonutil/jsonutil_test.go +++ b/jsonutil/jsonutil_test.go @@ -76,7 +76,7 @@ func TestMustUnmarshal(t *testing.T) { defer func() { rec := recover() if rec == nil { - t.Errorf("no panic?") + t.Error("no panic?") } }() diff --git a/maputil/maputil_test.go b/maputil/maputil_test.go index 88d3607..d6a2a47 100644 --- a/maputil/maputil_test.go +++ b/maputil/maputil_test.go @@ -21,7 +21,7 @@ func TestSwap(t *testing.T) { t.Run(fmt.Sprintf("test-%v", i), func(t *testing.T) { got := Swap(tc.in) if !reflect.DeepEqual(got, tc.expected) { - t.Errorf(diff.Cmp(tc.expected, got)) + t.Error(diff.Cmp(tc.expected, got)) } }) } diff --git a/ptrutil/ptr_test.go b/ptrutil/ptr_test.go index da2640f..a84e276 100644 --- a/ptrutil/ptr_test.go +++ b/ptrutil/ptr_test.go @@ -24,7 +24,7 @@ func TestDereference_Int(t *testing.T) { for i, test := range tests { t.Run(fmt.Sprintf("test-%d", i), func(t *testing.T) { if got := Dereference(test.ptr); got != test.expected { - t.Errorf(diff.Cmp(test.expected, got)) + t.Error(diff.Cmp(test.expected, got)) } }) } @@ -47,7 +47,7 @@ func TestDereference_String(t *testing.T) { for i, test := range tests { t.Run(fmt.Sprintf("test-%d", i), func(t *testing.T) { if got := Dereference(test.ptr); got != test.expected { - t.Errorf(diff.Cmp(test.expected, got)) + t.Error(diff.Cmp(test.expected, got)) } }) } diff --git a/sliceutil/sliceutil_test.go b/sliceutil/sliceutil_test.go index 7df4418..caa9162 100644 --- a/sliceutil/sliceutil_test.go +++ b/sliceutil/sliceutil_test.go @@ -34,7 +34,7 @@ func TestJoin(t *testing.T) { t.Run(fmt.Sprintf("test-%v", i), func(t *testing.T) { got := Join(tc.in) if got != tc.expected { - t.Errorf(diff.Cmp(tc.expected, got)) + t.Error(diff.Cmp(tc.expected, got)) } }) } @@ -77,7 +77,7 @@ func TestJoinWith(t *testing.T) { t.Run(fmt.Sprintf("test-%v", i), func(t *testing.T) { got := JoinWith(tc.in, tc.delim) if got != tc.expected { - t.Errorf(diff.Cmp(tc.expected, got)) + t.Error(diff.Cmp(tc.expected, got)) } }) } @@ -114,7 +114,7 @@ func TestUniq_Int64(t *testing.T) { t.Run(fmt.Sprintf("test-%v", i), func(t *testing.T) { got := Unique(tc.in) if !reflect.DeepEqual(got, tc.expected) { - t.Errorf(diff.Cmp(tc.expected, got)) + t.Error(diff.Cmp(tc.expected, got)) } }) } @@ -139,7 +139,7 @@ func TestUniq_String(t *testing.T) { t.Run(fmt.Sprintf("test-%v", i), func(t *testing.T) { got := Unique(tc.in) if !stringslicesequal(got, tc.expected) { - t.Errorf(diff.Cmp(tc.expected, got)) + t.Error(diff.Cmp(tc.expected, got)) } }) } @@ -165,7 +165,7 @@ func TestMergeUnique_Int64(t *testing.T) { got := MergeUnique(tc.in) if !int64slicesequal(got, tc.expected) { t.Log("IN", tc.in) - t.Errorf(diff.Cmp(tc.expected, got)) + t.Error(diff.Cmp(tc.expected, got)) } }) } @@ -274,11 +274,11 @@ func TestCSVtoInt64Slice(t *testing.T) { } if err != tc.expectedErr && err.Error() != tc.expectedErr.Error() { - t.Errorf(diff.Cmp(tc.expectedErr.Error(), err.Error())) + t.Error(diff.Cmp(tc.expectedErr.Error(), err.Error())) } if !reflect.DeepEqual(got, tc.expected) { - t.Errorf(diff.Cmp(tc.expected, got)) + t.Error(diff.Cmp(tc.expected, got)) } }) } @@ -301,7 +301,7 @@ func TestItemInSlice_String(t *testing.T) { t.Run(fmt.Sprintf("test-%v", i), func(t *testing.T) { got := Contains(tc.list, tc.find) if got != tc.expected { - t.Errorf(diff.Cmp(tc.expected, got)) + t.Error(diff.Cmp(tc.expected, got)) } }) } @@ -326,7 +326,7 @@ func TestInFoldedStringSlice(t *testing.T) { t.Run(fmt.Sprintf("test-%v", i), func(t *testing.T) { got := InFoldedStringSlice(tc.list, tc.find) if got != tc.expected { - t.Errorf(diff.Cmp(tc.expected, got)) + t.Error(diff.Cmp(tc.expected, got)) } }) } @@ -349,7 +349,7 @@ func TestItemInSlice_Int(t *testing.T) { t.Run(fmt.Sprintf("test-%v", i), func(t *testing.T) { got := Contains(tc.list, tc.find) if got != tc.expected { - t.Errorf(diff.Cmp(tc.expected, got)) + t.Error(diff.Cmp(tc.expected, got)) } }) } @@ -372,7 +372,7 @@ func TestItemInSlice_Int64(t *testing.T) { t.Run(fmt.Sprintf("test-%v", i), func(t *testing.T) { got := Contains(tc.list, tc.find) if got != tc.expected { - t.Errorf(diff.Cmp(tc.expected, got)) + t.Error(diff.Cmp(tc.expected, got)) } }) } @@ -657,7 +657,7 @@ func TestValues(t *testing.T) { return t.Name }) if !reflect.DeepEqual(got, tc.expected) { - t.Errorf(diff.Cmp(tc.expected, got)) + t.Error(diff.Cmp(tc.expected, got)) } }) } diff --git a/syncutil/syncmap_test.go b/syncutil/syncmap_test.go index 871b337..fbaaaf8 100644 --- a/syncutil/syncmap_test.go +++ b/syncutil/syncmap_test.go @@ -65,7 +65,7 @@ func TestMap_Range(t *testing.T) { m.Store(k, v) } - m.Range(func(k string, v int) bool { + m.Range(func(k string, _ int) bool { seen, ok := test[k] if !ok { t.Fatalf("unexpected key '%s'", k) @@ -95,7 +95,7 @@ func TestMap_Range_EarlyReturn(t *testing.T) { var count int - m.Range(func(k string, v int) bool { + m.Range(func(_ string, _ int) bool { count++ return false })