title: Array and slice data types
body: <p>I found myself confused with the <code>array</code> and <code>slice</code> data types.</p>
  
  <p>From Go docs, arrays are described as follows:</p>
  
  <blockquote>
    <p>There are major differences between the ways arrays work in Go and C. In Go,</p>
    
    <ul>
    <li>Arrays are values. Assigning one array to another copies all the elements.</li>
    <li>In particular, if you pass an array to a function, it will receive a copy of the array, not a pointer to it.</li>
    <li>The size of an array is part of its type. The types [10]int and [20]int are distinct.</li>
    </ul>
  </blockquote>
  
  <p>Functions:</p>
  
  <blockquote>
    <p>As in all languages in the C family, everything in Go is passed by
    value. That is, a function always gets a copy of the thing being
    passed, as if there were an assignment statement assigning the value
    to the parameter. For instance, passing an int value to a function
    makes a copy of the int, and passing a pointer value makes a copy of
    the pointer, but not the data it points to.</p>
  </blockquote>
  
  <p>Why does <code>sort.Ints(arrayValue)</code> modify the passed variable when I declared it as an array, not as a slice?</p>
  
  <p>Code</p>
  
  <pre><code>var av = []int{1,5,2,3,7}
  
  fmt.Println(av)
  sort.Ints(av)
  fmt.Println(av)
  return
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>[1 5 2 3 7]
  [1 2 3 5 7]
  </code></pre>