1st commit

This commit is contained in:
2024-02-06 15:26:20 +01:00
commit 014209898f
33 changed files with 984 additions and 0 deletions

21
util/generics.go Normal file
View File

@@ -0,0 +1,21 @@
package util
// find an item in a list, generic variant
func Contains[E comparable](s []E, v E) bool {
for _, vs := range s {
if v == vs {
return true
}
}
return false
}
// look if a key in a map exists, generic variant
func Exists[K comparable, V any](m map[K]V, v K) bool {
if _, ok := m[v]; ok {
return true
}
return false
}