Smarter describer for generic resources

This commit is contained in:
Fabiano Franz
2017-04-06 21:14:16 -03:00
parent 85bd965219
commit 151770c8fd
4 changed files with 166 additions and 0 deletions

View File

@@ -49,6 +49,20 @@ func ShuffleStrings(s []string) []string {
return shuffled
}
// ContainsString checks if a given slice of strings contains the provided string.
// If a modifier func is provided, it is called with the slice item before the comparation.
func ContainsString(slice []string, s string, modifier func(s string) string) bool {
for _, item := range slice {
if item == s {
return true
}
if modifier != nil && modifier(item) == s {
return true
}
}
return false
}
// Int64Slice attaches the methods of Interface to []int64,
// sorting in increasing order.
type Int64Slice []int64