I am seeing some "fatal error: concurrent map iteration and map write" on some old code written a while back. I've been trying to diagnose the issue, and I ran into a block of code similar to the below playground link.
It seems wrong to me to iterate on a returned map (which is passed by reference) even if it is returned in a function with a lock.
I was looking for an explanation about why this seems to not be throwing the above error.
I understand that there are RWMutex's and sync Maps now, but this code was written a while back, and I am looking for an explanation of the functionality as opposed to improvements.
https://play.golang.org/p/_RY-QAyGE2W
I would assume that the above code would throw "fatal error: concurrent map iteration and map write", however it seems to be working with no issue.