I have created a stack of struct in golang.
type Stack struct {
stack []StateContextStackCompartment
}
I have this struct and method to create a new struct instance:-
type StateContextStackCompartment struct {
State StateContextStackState
StateArgs map[string]interface{}
StateVars map[string]interface{}
EnterArgs map[string]interface{}
ExitArgs map[string]interface{}
_forwardEvent_ *framelang.FrameEvent
}
func NewStateContextStackCompartment(state StateContextStackState) *StateContextStackCompartment {
c := &StateContextStackCompartment{State: state}
c.StateArgs = make(map[string]interface{})
c.StateVars = make(map[string]interface{})
c.EnterArgs = make(map[string]interface{})
c.ExitArgs = make(map[string]interface{})
return c
}
case:-
I have added value and made changes. m._compartment is the pointer of StateContextStackCompartment
m._compartment_.StateVars["z"] = m._compartment_.StateVars["z"].(int) + 10
Example:-
- z value is 30
- push the pointer into the stack
- z value is changed to 40
Now z value with 40 is not pushed in the stack but the stack got updated with 40 from 30. Deep copy is not happening here. Can you help with what changes I must make before pushing the pointer into the stack?