mirror of
https://github.com/kemko/xc.git
synced 2026-01-01 15:55:43 +03:00
17 lines
349 B
Go
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
|
|
}
|