@kyanny's blog

My thoughts, my life. Views/opinions are my own.

Go: pass by pointer vs pass by value

goinbigdata.com

公式っぽい文書↓

CodeReviewComments · golang/go Wiki · GitHub

  • ポインタで渡さなければいけない場合
  • 構造体が大きい場合
    • How large is large? Assume it's equivalent to passing all its elements as arguments to the method. If that feels too large, it's also too large for the receiver.

Passing by value often is cheaper らしいので(コンパイラの最適化が効くから)、必要でなければ pass by value で良いのかもしれない。