No, map assignment is not atomic. Also, your reassignment of the global
data map with the
temp one you created is not atomic.
If your idea is to initialize a map and then store it into a global variable where it will be considered read-only, you can do that with the
sync/atomic package and some pointer hackery: https://play.golang.org/p/3UmzbTT0Pcl
If the global map is supposed to remain mutable, then you need to protect access with a mutex: https://play.golang.org/p/khh7W9NnHNi
Both of these solutions, I think, would be frowned upon by other Go developers, though. You should be using a higher-level abstraction to control access to the map, but I can’t provide a good example without knowing how you plan on using the map.