Using Struct Value in Map

"cannot assign to struct field in map"

Fix the 'cannot assign to struct field in map' error by retrieving the struct, modifying it, and reassigning it to the map key.

You cannot modify a struct field directly because the struct value inside the map is a copy, not an addressable variable. Retrieve the struct, modify it, and assign it back to the map.

m := map[string]MyStruct{"key": {}}
m["key"].Field = 10 // Error: cannot assign to struct field in map

// Fix: Retrieve, modify, reassign
s := m["key"]
s.Field = 10
m["key"] = s