You have a map of string
to the value of TeamRow
so when you get the val
out of the map it returns the value of the team, not a pointer to the team. If you make the map a string to the pointer of TeamRow
then when you get the val out it will point to the memory that is stored in the map so values will persist beyond the scope of your AddLoss
function. To do this simply add a *
to the map declaration – teamMap map[string]*TeamRow
though when you populate it you will then also need to store pointers in the map.
1
solved How to update a struct property in a map [duplicate]