NotePublic/Software/Development/Language/Go/Basic/Golang_Map.md

253 B

Golang Map

// 定义
var mymap map[string]string

// 创建
mymap = make(map[string]string)

// 添加/赋值
mymap["a"] = "A"

// 删除
delete(mymap, "a")

// 清空
for k, _ := range mymap {
    delete(mymap, k)
}

// 释放
mymap = nil