Inital commit

This commit is contained in:
2026-01-02 05:00:07 +01:00
commit 950aaffcc7
14 changed files with 1864 additions and 0 deletions

45
utils/strings.go Normal file
View File

@@ -0,0 +1,45 @@
package utils
import "strings"
func Strip(s string) string {
var result strings.Builder
for i := 0; i < len(s); i++ {
b := s[i]
if ('a' <= b && b <= 'z') ||
('A' <= b && b <= 'Z') ||
('0' <= b && b <= '9') {
result.WriteByte(b)
}
}
return result.String()
}
func DedupeSlice[T comparable](sliceList []T) []T {
dedupeMap := make(map[T]struct{})
list := []T{}
for _, slice := range sliceList {
if _, exists := dedupeMap[slice]; !exists {
dedupeMap[slice] = struct{}{}
list = append(list, slice)
}
}
return list
}
func Check(e error) {
if e != nil {
panic(e)
}
}
func Filter[T any](ss []T, test func(T) bool) (ret []T) {
for _, s := range ss {
if test(s) {
ret = append(ret, s)
}
}
return
}