Posts

Showing posts from April, 2022

Golang Maps Tutorial | Golang Maps Explained from Scratch

  What is Map In Golang? Maps are a convenient and powerful built-in data structure that associate values of one type (the  key ) with values of another type (the  element  or  value ). The key can be of any type for which the equality operator is defined, such as integers, floating point and complex numbers, strings, pointers, interfaces (as long as the dynamic type supports equality), structs and arrays. Slices cannot be used as map keys, because equality is not defined on them. Like slices, maps hold references to an underlying data structure. If you pass a map to a function that changes the contents of the map, the changes will be visible in the caller. Maps can be constructed using the usual composite literal syntax with colon-separated key-value pairs, so it's easy to build them during initialization. For more context you can compare golangs' map as pythons' dictionary and as well nodejs' object. How to Create Map? A map can be created by passing the type ...