* Added command and query for organizations * Saving unknown organizations into database in `background` service * Added `List` method in `OrganizationRepository`
16 lines
294 B
Go
16 lines
294 B
Go
package xslices
|
|
|
|
func ForEach[T any](items []T, f func(T)) {
|
|
for _, item := range items {
|
|
f(item)
|
|
}
|
|
}
|
|
|
|
func AsMap[T any, U comparable](items []T, f func(T) U) map[U]struct{} {
|
|
out := make(map[U]struct{}, len(items))
|
|
ForEach(items, func(in T) {
|
|
out[f(in)] = struct{}{}
|
|
})
|
|
return out
|
|
}
|