In my code I create a map pointer which I then dereference to retrieve an item.
a := "...big JSON string..."
b := map[string]B{}
json.Unmarshal(a, &b)
c.my_map = &b
...
// and my fetch function does:
result = (*c.my_map)[id]
When dereferencing that map pointer, does it create a temporary copy of the map in memory?
i.e. when I do:
d := *c.my_map
I know I get a copy of the map in d
(not a deep copy, but the map itself is duplicated), so I'm thinking that the statement above could end up copying everything...
Why the pointer?
The map is loaded by a go routine and then I save the final pointer in my struct. That save happens with a lock. The loading can be very long (Gb of data) so that's why... (now reading the answer by Zuko) it doesn't look like it would be required at all since a map is passed around as a reference anyway.