Question

I'm interested in the following:

  • How are Go maps implemented internally? (hash tables, trees...)
  • If Go maps are hash tables, which hash function is used?
  • If Go maps are trees, are they AVL, red-black, or some other type?
  • If Go maps are array-based, how do they avoid/handle collisions?
Was it helpful?

Solution

Go maps are hash tables internally

As @twotwotwo clarified in the comment, Go will use an AES-based hash if the CPU has supporting instructions for it.

Otherwise Go will use a FNV hash function (As stated by Patrick Mylund Nielsen @ Go-Nuts)

Links:

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top