Const reference in C++ and equivalent in Golang
<p>I came to go from the C++ world and in C++ usually when you care about performance and you don't need you object to be changed, you pass it using constant reference</p>

<pre><code>void func(const std::string&amp; str)
</code></pre>

<p>In this case, the string is NOT COPIED and cannot be modified in the function.</p>

<p>I know, that in Go there are two ways to pass object:</p>

<ul>
<li>By value, and then you cannot modify (or actually you can but it makes no sense) it, but it very memory consuming</li>
<li>By pointer, this is good from the terms of memory, but you can modify object.</li>
</ul>

<p>So, what is best approach? Always pass object by pointer even if you don't want to modify it because it is faster? Or there are some compiler optimizations and even if you send it by value sometimes it is sent as reference?</p>