dorfylegends/backend/util/util.go

29 lines
525 B
Go
Raw Normal View History

2022-04-09 19:37:44 +03:00
package util
import "strings"
func Keys[K comparable, V any](input map[K]V) []K {
keys := make([]K, 0, len(input))
for k := range input {
keys = append(keys, k)
}
return keys
}
func Values[K comparable, V any](input map[K]V) []V {
values := make([]V, 0, len(input))
for _, v := range input {
values = append(values, v)
}
return values
}
func ContainsAny(s string, substrings ...string) bool {
for _, substring := range substrings {
if strings.Contains(s, substring) {
return true
}
}
return false
}