Skip to content

Commit 7869872

Browse files
authored
Add v0 compatibility functions (#82)
* Add v0 compatibility functions bunch of dependants still use a version before generics this will help migration to be done progressively * lovely lint
1 parent ea51bfb commit 7869872

File tree

10 files changed

+483
-25
lines changed

10 files changed

+483
-25
lines changed

aesutil/aesutil_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ func TestInvalidKeysAndData(t *testing.T) {
1818
data := []byte(testPlaintext)
1919
_, err := Encrypt("", data)
2020
if err == nil {
21-
t.Errorf("Encrypt succeeded with an empty key")
21+
t.Error("Encrypt succeeded with an empty key")
2222
}
2323

2424
// Decrypt with empty key
2525
_, err = Decrypt("", testCiphertext)
2626
if err == nil {
27-
t.Errorf("Decrypt succeeded with an empty key")
27+
t.Error("Decrypt succeeded with an empty key")
2828
}
2929

3030
// Decrypt with an incorrect key
@@ -48,13 +48,13 @@ func TestInvalidKeysAndData(t *testing.T) {
4848
// Decrypt an short string (i.e. smaller than block size)
4949
_, err = Decrypt(testKeyString, "aaaabbbbcccc")
5050
if err == nil {
51-
t.Errorf("Decrypt succeeded with an invalid key size")
51+
t.Error("Decrypt succeeded with an invalid key size")
5252
}
5353

5454
// Decrypt a non-base64 string
5555
_, err = Decrypt(testKeyString, fmt.Sprintf("%s#@?`", testCiphertext))
5656
if err == nil {
57-
t.Errorf("Decrypt succeeded with an invalid base64 string")
57+
t.Error("Decrypt succeeded with an invalid base64 string")
5858
}
5959
}
6060

@@ -87,7 +87,7 @@ func TestEncryptAndDecrypt(t *testing.T) {
8787
t.Fatal("Decrypt failed, plaintext result is nil")
8888
}
8989
if string(plain) != testData {
90-
t.Fatalf(diff.Cmp(testData, string(plain)))
90+
t.Fatal(diff.Cmp(testData, string(plain)))
9191
}
9292
})
9393
}

goutil/goutil.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func ResolveWildcard(path string, mode build.ImportMode) ([]*build.Package, erro
9696

9797
// Gather a list of directories with *.go files.
9898
goDirs := make(map[string]struct{})
99-
err = filepath.Walk(root.Dir, func(path string, info os.FileInfo, err error) error {
99+
err = filepath.Walk(root.Dir, func(path string, info os.FileInfo, _ error) error {
100100
if !strings.HasSuffix(path, ".go") || info.IsDir() || strings.Contains(path, "/vendor/") {
101101
return nil
102102
}

ioutilx/copy_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ func TestCopyTree(t *testing.T) {
312312

313313
err := CopyTree("test", "test_copytree", &CopyTreeOptions{
314314
Symlinks: false,
315-
Ignore: func(path string, fi []os.FileInfo) []string {
315+
Ignore: func(_ string, _ []os.FileInfo) []string {
316316
return []string{"fifo"}
317317
},
318318
CopyFunction: Copy,

jsonutil/jsonutil_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func TestMustUnmarshal(t *testing.T) {
7676
defer func() {
7777
rec := recover()
7878
if rec == nil {
79-
t.Errorf("no panic?")
79+
t.Error("no panic?")
8080
}
8181
}()
8282

maputil/maputil_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func TestSwap(t *testing.T) {
2121
t.Run(fmt.Sprintf("test-%v", i), func(t *testing.T) {
2222
got := Swap(tc.in)
2323
if !reflect.DeepEqual(got, tc.expected) {
24-
t.Errorf(diff.Cmp(tc.expected, got))
24+
t.Error(diff.Cmp(tc.expected, got))
2525
}
2626
})
2727
}

ptrutil/ptr_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func TestDereference_Int(t *testing.T) {
2424
for i, test := range tests {
2525
t.Run(fmt.Sprintf("test-%d", i), func(t *testing.T) {
2626
if got := Dereference(test.ptr); got != test.expected {
27-
t.Errorf(diff.Cmp(test.expected, got))
27+
t.Error(diff.Cmp(test.expected, got))
2828
}
2929
})
3030
}
@@ -47,7 +47,7 @@ func TestDereference_String(t *testing.T) {
4747
for i, test := range tests {
4848
t.Run(fmt.Sprintf("test-%d", i), func(t *testing.T) {
4949
if got := Dereference(test.ptr); got != test.expected {
50-
t.Errorf(diff.Cmp(test.expected, got))
50+
t.Error(diff.Cmp(test.expected, got))
5151
}
5252
})
5353
}

sliceutil/compatibility.go

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package sliceutil
2+
3+
// JoinInt see Join
4+
// Deprecated: use Join
5+
func JoinInt(ints []int64) string {
6+
return Join(ints)
7+
}
8+
9+
// UniqInt64 see Unique
10+
// Deprecated: use Unique
11+
func UniqInt64(list []int64) []int64 {
12+
return Unique(list)
13+
}
14+
15+
// UniqString see Unique
16+
// Deprecated: use Unique
17+
func UniqString(list []string) []string {
18+
return Unique(list)
19+
}
20+
21+
// UniqueMergeSlices see MergeUnique
22+
// Deprecated: use MergeUnique
23+
func UniqueMergeSlices(s [][]int64) (result []int64) {
24+
return MergeUnique(s)
25+
}
26+
27+
// InStringSlice see Contains
28+
// Deprecated: use Contains
29+
func InStringSlice(list []string, str string) bool {
30+
return Contains(list, str)
31+
}
32+
33+
// InIntSlice see Contains
34+
// Deprecated: use Contains
35+
func InIntSlice(list []int, i int) bool {
36+
return Contains(list, i)
37+
}
38+
39+
// InInt64Slice see Contains
40+
// Deprecated: use Contains
41+
func InInt64Slice(list []int64, i int64) bool {
42+
return Contains(list, i)
43+
}
44+
45+
// RepeatString see Repeat
46+
// Deprecated: use Repeat
47+
func RepeatString(s string, n int) (r []string) {
48+
return Repeat(s, n)
49+
}
50+
51+
// ChooseString see Choose
52+
// Deprecated: use Choose
53+
func ChooseString(l []string) string {
54+
return Choose(l)
55+
}
56+
57+
// FilterString see Filter
58+
// Deprecated: use Filter
59+
func FilterString(list []string, fun func(string) bool) []string {
60+
return Filter(list, fun)
61+
}
62+
63+
// RemoveString see Remove
64+
// Deprecated: use Remove
65+
func RemoveString(list []string, s string) (out []string) {
66+
return Remove(list, s)
67+
}
68+
69+
// FilterStringEmpty see FilterEmpty
70+
// Deprecated: use FilterEmpty
71+
func FilterStringEmpty(e string) bool {
72+
return FilterEmpty(e)
73+
}
74+
75+
// FilterInt see Filter
76+
// Deprecated: use Filter
77+
func FilterInt(list []int64, fun func(int64) bool) []int64 {
78+
return Filter(list, fun)
79+
}
80+
81+
// StringMap see Map
82+
// Deprecated: use Map
83+
func StringMap(list []string, f func(string) string) []string {
84+
return Map(list, f)
85+
}

0 commit comments

Comments
 (0)