PosString returns the first index of element in slice. If slice does not contain element, returns -1.
(slice []string, element string)
| 27 | // PosString returns the first index of element in slice. |
| 28 | // If slice does not contain element, returns -1. |
| 29 | func PosString(slice []string, element string) int { |
| 30 | for index, elem := range slice { |
| 31 | if elem == element { |
| 32 | return index |
| 33 | } |
| 34 | } |
| 35 | return -1 |
| 36 | } |
| 37 | |
| 38 | // RemoveItemFromSlice returns a slice with item removed |
| 39 | // If the item does not exist, the slice is unchanged |
no outgoing calls