I am currently learning to program with Go language. I am having some difficulties understanding Go pointers (and my C/C++ is far away now...). In the Tour of Go #52 (http://tour.golang.org/#52) for example, I read:
type Vertex struct {
X, Y float64
}
func (v *Vertex) Abs() float64 {
return math.Sqrt(v.X*v.X + v.Y*v.Y)
}
func main() {
v := &Vertex{3, 4}
fmt.Println(v.Abs())
}
But if instead of
func (v *Vertex) Abs() float64 {
[...]
v := &Vertex{3, 4}
I wrote:
func (v Vertex) Abs() float64 {
[...]
v := Vertex{3, 4}
Or even:
func (v Vertex) Abs() float64 {
[...]
v := &Vertex{3, 4}
and vice-versa:
func (v *Vertex) Abs() float64 {
[...]
v := Vertex{3, 4}
I got the exact same result. Is there a difference (memory-wise, etc)?