关于golang中`&MyType {}`模式的任何文档/文章吗?

In most golang codebases I look, people are using types by reference:

type Foo struct {}
myFoo := &Foo{}

I usually take the opposite approach, passing everything as copy and only pass by reference when I want to perform something destructive on the value, which allows me to easily spot destructive functions (and which is fairly rare).

But seeing how references are commonplace, I guess it's not just a matter of taste. I get there's a cost in duplicating values, is it that much of a game changer? Or are there other reasons why references are preferred?

It would be great if someone could point me to an article or documentation about why references are preferred.

Thanks!

Go is pass by value. I try to use references like in your example as much as possible to remove the mental process of thinking about not making duplicates of objects. Go is mostly meant for networking & scaling, which makes performance a priority. Obvious downside of this is as you say, receiving methods can destroy the object that the pointer points to.

Otherwise there is no rule as to which you should use. Both are quite ok.

Also, somewhat related to the question, from the Go docs: Pointers vs. Values