18 lines
311 B
Go
18 lines
311 B
Go
package utils
|
|
|
|
type ObjectType []interface{}
|
|
|
|
func ForEach[T any](arr *[]T, fun func(item *T)) {
|
|
for i := range *arr {
|
|
fun(&((*arr)[i]))
|
|
}
|
|
}
|
|
|
|
func Map[T any, V any](arr []T, fun func(item T) V) []V {
|
|
res := make([]V, 0, len(arr))
|
|
for _, item := range arr {
|
|
res = append(res, fun(item))
|
|
}
|
|
return res
|
|
}
|