Your method receiver is the value of the structure, which means that the recipient receives a copy of the structure when called, so it enlarges the copy, and your original is not updated.
To see updates, put your method on the structure pointer.
func (self *Counter) increment() { self.count++ }
Now self is a pointer to your counter variable, and so it will update its value.
http://play.golang.org/p/h5dJ3e5YBC
user1106925
source share