feat: add local storage for firefox

This commit is contained in:
ᴍᴏᴏɴD4ʀᴋ
2022-04-19 21:28:43 +08:00
parent f5c3e6da5e
commit 121e49bdff
8 changed files with 213 additions and 9 deletions
+8
View File
@@ -23,6 +23,14 @@ func IntToBool[T constraints.Signed](a T) bool {
return true
}
func Reverse[T any](s []T) []T {
var h = make([]T, len(s))
for i := 0; i < len(s); i++ {
h[i] = s[len(s)-i-1]
}
return h
}
func TimeStamp(stamp int64) time.Time {
s := time.Unix(stamp, 0)
if s.Local().Year() > 9999 {
+24
View File
@@ -0,0 +1,24 @@
package typeutil
import (
"testing"
)
var (
reverseTestCases = [][]any{
[]any{1, 2, 3, 4, 5},
[]any{"1", "2", "3", "4", "5"},
[]any{"1", 2, "3", "4", 5},
}
)
func TestReverse(t *testing.T) {
for _, ts := range reverseTestCases {
h := Reverse(ts)
for i := 0; i < len(ts); i++ {
if h[len(h)-i-1] != ts[i] {
t.Errorf("reverse failed %v != %v", h, ts)
}
}
}
}