映射被实现为哈希表。有很多地方可以解释散列; 这是一个很好的可视化,你可以运行。Go 的一个不错的特性是源代码在 github 上可用,并且它写得很好,文档也很好,所以理解起来并不难。从 hashmap 的源文件:// A map is just a hash table. The data is arranged// into an array of buckets. Each bucket contains up to// 8 key/value pairs. The low-order bits of the hash are// used to select a bucket. Each bucket contains a few// high-order bits of each hash to distinguish the entries// within a single bucket.//// If more than 8 keys hash to a bucket, we chain on// extra buckets.https://github.com/golang/go/blob/master/src/runtime/map.go您可以从这段代码中学到的一件事通常不会在很多类中涵盖,那就是如何在内部调整地图大小时不使迭代器无效。