Go - Map

About

Map in Go.

A map is a reference structure created by make.

Example

A map with a string as key and an int as value.

counts := make(map[string]int)

Management

Get the key

keys := []string(reflect.ValueOf(myMap).MapKeys())
# or
keys := make([]int, len(mymap))
i := 0
for k := range mymap {
    keys[i] = k
    i++
}

Get the value (Map Lookup)

v, ok = m[key] 

where;

  • ok is a Boolean

Powered by ComboStrap