Are slices passed by value?
<p>In Go, I am trying to make a scramble slice function for my traveling salesman problem. While doing this I noticed when I started editing the slice I gave the scramble function was different every time I passed it in.</p>
<p>After some debugging I found out it was due to me editing the slice inside the function. But since Go is supposed to be a &quot;pass by value&quot; language, how is this possible?</p>
<p><a href="https://play.golang.org/p/mMivoH0TuV" rel="noreferrer">https://play.golang.org/p/mMivoH0TuV</a></p>
<p>I have provided a playground link to show what I mean.
By removing line 27 you get a different output than leaving it in, this should not make a difference since the function is supposed to make its own copy of the slice when passed in as an argument.<br />
Can someone explain the phenomenon?</p>