feat: add universities and restaurants (#4)

Features:
- Allow to search for individual resources by their name
- Add new resources and their handler: Universities, Restaurants
- Added new parameter to reverse output order

Reviewed-on: #4
Co-authored-by: bdoerfchen <git@bissendorf.co>
Co-committed-by: bdoerfchen <git@bissendorf.co>
This commit is contained in:
2025-07-20 22:13:03 +00:00
committed by bissendorf
parent e395b0b4ca
commit 4b7866da03
20 changed files with 408 additions and 33 deletions

View File

@ -31,3 +31,18 @@ func Map[T any, Tkey comparable, Tval any](s []T, transformFn func(i *T) (Tkey,
return
}
func Group[T any, Tkey comparable, Tval any](s []T, groupFn func(i *T) (groupKey Tkey, value Tval)) (out map[Tkey][]Tval) {
out = make(map[Tkey][]Tval)
for _, i := range s {
key, value := groupFn(&i)
list, exists := out[key]
if !exists {
list = make([]Tval, 0, 2)
}
out[key] = append(list, value)
}
return
}