Middlewares
This commit is contained in:
11
backend/utils/contains.go
Normal file
11
backend/utils/contains.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package utils
|
||||
|
||||
func Contains[T comparable](arr []T, el T) bool {
|
||||
for _, a := range arr {
|
||||
if a == el {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
9
backend/utils/map.go
Normal file
9
backend/utils/map.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package utils
|
||||
|
||||
func Map[T any, U any](input []T, fn func(T) U) []U {
|
||||
var result []U
|
||||
for _, v := range input {
|
||||
result = append(result, fn(v))
|
||||
}
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user