Go入门笔记29-Map使用

1、声明初始化Map

var testMap map[string]string
testMap = make(map[string]string)

2、判断Map是否有指定键

if _, ok := testMap[key]; ok {
}

3、新添或更新指定键元素

testMap[key] = newItem

4、删除指定键元素

delete(testMap, key)
posted @ 2021-08-25 22:23  zhaogaojian  阅读(39)  评论(0编辑  收藏  举报