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

24 lines
253 B
Markdown
Raw Normal View History

# Golang Map
```go
// 定义
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
```