go language map dictionary delete operation method
- 2020-05-24 05:41:50
- OfStack
This article illustrates an example of go language map dictionary deletion. Share with you for your reference. The specific analysis is as follows:
Here, 1 point map is constructed first, adding pinyin and Chinese dictionary of Qingdao, jinan and yantai, then deleting Qingdao, and finally checking whether Qingdao still exists
package main
import "fmt"
func main(){
var pc map[string] string
pc = make(map[string] string)
pc["qingdao"] = " Qingdao "
pc["jinan"] = " jinan "
pc["yantai"] = " yantai "
delete(pc,"qingdao")
qingdao,ok := pc["qingdao"]
if ok{
fmt.Println(qingdao)
}else{
fmt.Println(" Elements don't exist ")
}
}
I hope this article has been helpful to your programming of Go language.