package main
import (
"fmt"
)
func main() {
arr := []string{"go", "c++", "php", "python"}
_, found := Find(arr, "abc")
if !found {
fmt.Println("not found")
}
i, found := Find(arr, "php")
if !found {
fmt.Println("not found")
}
fmt.Printf("found at index: %d\n", i)
}
func Find(slice []string, val string) (int, bool) {
for i, item := range slice {
if item == val {
return i, true
}
}
return -1, false
}
/*
run:
not found
found at index: 2
*/