The Golang map is the same as the Hash map, but the GO allocation process has its own unique way. Check out the golang Map principle article. But why is map not thread-safe?

Because of the memory is in accordance with the power of 2 hash map, the memory of surface settlement, will be a new section of memory, the original memory data transfer to the new memory block, this process is not locked, if this time have a read threads at the same time to come over to get the memory data, security problems will occur.

Concurrent map writes may occur when multiple Goroutines operate concurrent map writes. Implement a map structure with read/write locks. It is recommended to use Golang’s sync.map. Good performance and easy to use.