How does go determine if key is in slice?

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?


write one yourself.

urls := make([string]struct{})

if url in urls{
    // do 
} else {
    // do 
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b372dc-2b7ee.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b372dc-2b7ee.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?