Maps

https://blog.golang.org/go-maps-in-action

Table of Contents

Basics of map tutorial

map[KeyType]ValueType
Declare / init a map
Iterate over a map
Get an element in a map
Delete(remove) an element from a map

Mimic set type with a map howto

m := make(map[string]bool)
if !m[x] {
    m[x] = true
}

Implement a nested map which works like a defaultdict in Python howto

graph := make(map[string]map[string]bool)

func addEdge(from, to string) {
    edges := graph[from]
    if edges == nil {
        edges = make(map[string]bool)
        graph[from] = edges
    }
    edges[to] = true
}