I spent half day debugging the test due to this reason. When populating Golang map and slice in a loop, we should store the object itself rather than pointer. Otherwise, the pointer will be updated in next iteration of the loop. For example, in this code block, all the values in the map will be updated to last replicaset. Very different from Java.