Choose Category
package main import ( "fmt" "sort" ) func main() { personNameSlice := make([]string, 0) personNameSlice = append(personNameSlice, "hello") personNameSlice = append(personNameSlice, "world") searchedIndex := sort.SearchStrings(personNameSlice, "world") if searchedIndex < len(personNameSlice) { fmt.Printf("Element is found in index %d \n", searchedIndex) personNameSlice = removeIndex(personNameSlice, searchedIndex) fmt.Printf("%v \n", personNameSlice) } else { fmt.Printf("Element not found") } } func removeIndex(slice []string, index int) []string { return append(slice[:index], slice[index+1:]...) }