From the course: Transition from Java to Go

Unlock the full course today

Join today to access over 24,100 courses taught by industry experts.

Maps

Maps

- [Instructor] We know how to create static and dynamic arrays, but it's time to explore maps. Go's inbuilt maps are hash table implementations that allow us to save key-value pairs. They are simple types that provide functionality for lookup, adding, and deleting entries. The type of the map specifies the key type and the value type. Only these specified types can be saved in this map. This is the same as we'd expect with Java hash tables. Similarly to slices, they are initialized using the make function. The make function takes in the map type and sets up the underlying data structures required for it. The make function also takes an optional size parameter. Maps are dynamically resized, so the size is a hint, not a limitation. For example, make map string int creates a map using a string key type and an int value type. Maps are composite data types which use pointers under the hood. Unless initialized, the zero value…

Contents