1 min readOct 15, 2017
Let me give a breakdown in stages:
- declare
value := 1
reset(value)
did set the value to 0, how can you confirm this? Move the print statement to the end of thereset()
method and it will log 0.
3. fmt.Println("after reset", value)
, the value that’s printed here says, “oh, what’s the current value stored in value
address, it doesn’t go into the reset()
to find the value but rather just looks up the value in the memory location which wasn’t altered, thus the no change
.
The part that eventually changes the value says “hey, give me a pointer to the address of the value and any change done is global, alters the real value everywhere else”
I hope that explains it a bit. Let me know if it’s still a bit unclear.