mirror of
https://github.com/chubin/cheat.sheets
synced 2024-11-19 03:25:44 +00:00
17 lines
328 B
Plaintext
17 lines
328 B
Plaintext
var m map[string]int
|
|
m = make(map[string]int)
|
|
m["key"] = 42
|
|
fmt.Println(m["key"])
|
|
|
|
// delete key from a map
|
|
delete(m, "key")
|
|
|
|
// test if key "key" is present and retrieve it, if so
|
|
elem, ok := m["key"]
|
|
|
|
// map literal
|
|
var m = map[string]Vertex{
|
|
"Bell Labs": {40.68433, -74.39967},
|
|
"Google": {37.42202, -122.08408},
|
|
}
|