Documentation ¶
Overview ¶
Package sliceutil contains some slice related helper functions.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IndexOf ¶
func IndexOf(val interface{}, slice interface{}) int
IndexOf returns the first index at which a given element can be found in the slice, or -1 if it is not present. The second argument must be a slice or array.
Example ¶
package main import ( "fmt" "github.com/upyun/utilgo/sliceutil" ) func main() { s := []string{"a1", "a2", "aa"} { v := "aa" i := sliceutil.IndexOf(v, s) fmt.Println(i) } { v := "bb" i := sliceutil.IndexOf(v, s) fmt.Println(i) } }
Output: 2 -1
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.