I have a struct
type keeper struct {
ptr int32
}
then I add a function to it
func(l keeper) next() {
l.ptr++
}
But when I create a new keeper and call next()
tester := keeper {
ptr: 0,
}
test.next()
It seems I am not modifying the ptr value within tester. If I change the function to be a pointer it then works
func(l *keeper) next() {
l.ptr++
}
Why so?