January 2018
Intermediate to advanced
340 pages
8h 6m
English
A map is a hash table or dictionary that stores key and value pairs. The key and value can be any data types, including maps themselves, creating multiple dimensions.
The order is not guaranteed. You can iterate over a map multiple times and it might be different. Additionally, maps are not concurrent safe. If you must share a map between threads, use a mutex.
Here are some example map usages:
package mainimport ( "fmt" "reflect")func main() { // Nil maps will cause runtime panic if used
// without being initialized with make() var intToStringMap map[int]string var stringToIntMap map[string]int fmt.Println(reflect.TypeOf(intToStringMap)) fmt.Println(reflect.TypeOf(stringToIntMap)) // Initialize a map using make map1 := make(map[string]string) ...Read now
Unlock full access