In this example on the go playground, you can see that looping over a list of objects and putting them into an array of pointer structs ends up putting the same entry into the array multiple times.
http://play.golang.org/p/rICA21kFWL
One possible solution to the issue is to make a new string and sprint the string out of the looped string into the new string. This seems silly though.
What is the idiomatically correct way to handle this problem?
In case I understood correctly and you simply want an array of pointers pointing to the respective string in the original array, you can always do this
# choose correct size from beginning to avoid costly resize
o := make([]*string, len(f))
# iterate only over index
for i := range f {
o[i] = &f[i].username
}
Here's your go playground with the changes sketched out above.