MCPcopy Index your code
hub / github.com/ddev/ddev / PosString

Function PosString

pkg/nodeps/utils.go:29–36  ·  view source on GitHub ↗

PosString returns the first index of element in slice. If slice does not contain element, returns -1.

(slice []string, element string)

Source from the content-addressed store, hash-verified

27// PosString returns the first index of element in slice.
28// If slice does not contain element, returns -1.
29func 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

Callers 3

TestPosStringFunction · 0.92
ArrayContainsStringFunction · 0.85
RemoveItemFromSliceFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestPosStringFunction · 0.74