IndexFunc

Returns the index of the first element in the slice that satisfies the given predicate, or -1 if no such element exists.


slices.IndexFunc([]int{10, 20, 30}, func(v int) bool {
    return v == 30
})
                        
introduction.go