mirror of
https://github.com/portainer/portainer.git
synced 2026-06-23 07:00:14 +00:00
11 lines
214 B
Go
11 lines
214 B
Go
package slicesx
|
|
|
|
func GroupBy[A any, K comparable](input []A, f func(A) K) map[K][]A {
|
|
result := make(map[K][]A)
|
|
for _, v := range input {
|
|
key := f(v)
|
|
result[key] = append(result[key], v)
|
|
}
|
|
return result
|
|
}
|