From this code snippet, it looks like it’s not using a lock to get a snapshot list of the map because of data races, it just saves some troublesome work. You can try viewing the source code of MapKeys.
Git blame sheds some light on the question here. In short, they wanted this algorithm to be more deterministic than simply iterating over map keys, since the order of keys access is random.
But why not build an array of all keys and sort it without using reflection?
The missing mutex for access the data structure looks wrong also, not sure how MapKeys would alleviate this problem.
Reading the map source code of golang show that there are actually two different map implementation: the experimental SwissMap and this great blog post I found