Example analysis of Go language map dictionary usage
- 2020-05-24 05:41:54
- OfStack
This article illustrates the use of the Go language map dictionary. Share with you for your reference. The specific analysis is as follows:
The code generates a dictionary of pinyin and Chinese characters for Qingdao, jinan and yantai, which can be used to output Chinese characters
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 "
qingdao,ok := pc["qingdao"]
if ok{
fmt.Println(qingdao)
}
}
I hope this article has been helpful to your programming of Go language.