Files
xc/stringslice/stringslice.go
Pavel Vorobyov 7e2dec0ef0 project move
2019-09-24 11:04:48 +03:00

17 lines
349 B
Go

package stringslice
// Index returns the index of item in a given array
func Index(arr []string, item string) int {
for i := 0; i < len(arr); i++ {
if item == arr[i] {
return i
}
}
return -1
}
// Contains returns true if the given array contains given item
func Contains(arr []string, item string) bool {
return Index(arr, item) >= 0
}