In computer science, a map is a data structure that associates (or maps) one value to another. Maps can be implemented in several ways, each with its own trade-offs. The map that’s built into Go is a hash map, or hash table. If you aren’t familiar with the concept, the related discussion in Grokking Algorithms by Aditya Bhargava (Manning) describes what a hash table is and why they are so useful.
It’s great that Go includes a hash map implementation as part of the runtime, because building your own is hard to get right. It’s also great because the implementation gets better over time. In Go 1.24, the runtime was updated with a new hash table algorithm that improved performance on microbenchmarks by up to 60%. Go developers got this faster version by simply recompiling their code. You can learn about the details of the updated algorithm in Michael Pratt’s 2025 blog post “Faster Go maps with Swiss Tables”.
Go doesn’t require (or even allow) you to define your own hash algorithm or equality definition. Instead, the Go runtime that’s compiled into every Go program has code that implements hash algorithms for all types that are allowed to be keys.