http://play.golang.org/p/wYgfLLQYdm
See example above. In my example the variable change does not last after the method is executed. How can I change a struct variable's value with a struct method?
http://play.golang.org/p/wYgfLLQYdm
See example above. In my example the variable change does not last after the method is executed. How can I change a struct variable's value with a struct method?
Your method receiver is a value, not a pointer.
That means those methods like switch_width_height() operate on a copy of the object.
See also:
Add a '*':
func (s *square) switch_width_height()
And it will work as expected: see play.golang.org.