>There are no reference types in Go, everything in Go is passed by value.
Yes, but this value is not the ACTUAL value (e.g the underlying storage).
When people (especially newcomers to pointers like the person that started this thread) speak of "pass by value" they refer to their data (the actual value).
So that Go passes _the structure_ by value is quite misleading, compared to the expectation of what "pass by value" means.
For practical purposes, I think they're better off to think of it as a reference.
>>For practical purposes, I think they're better off to think of it as a reference.
No, they should learn to understand what is actually happening. Otherwise things, at best, do not make sense and, at worst, can lead to bugs when using functions like append(): http://play.golang.org/p/eTJXu6XMNJ
Re:Go 1.1 is released
by bishop_mandible on Tuesday May 14, 2013 @12:56AM
(#5703078)
> a structure that has a pointer to the underlying data by value
Isn't this the exact definition of a reference type?
When you pass a slice, for example, you are passing a structure that has a pointer to the underlying data by value; you could think of it as a reference BUT its not what you think it is. What you are passing around is actually a struct that is passed by value:
1: http://golang.org/pkg/reflect/#SliceHeader