how is it convenient to define a slice, if you want to determine whether the key is in the slice?
The code is as follows:
func main () {
urls := []string{
"https://www.aaa.com",
"https://www.bbb.com",
"https://www.ccc.com",
"https://www.ddd.com/",
}
fmt.Println(urls[6])
}
output result is
panic: runtime error: index out of range
goroutine 1 [running]:
main.main ()
is there any function that can directly determine whether key is in slice?