title: Is there analog of memset in go?
body: <p>In C++ I can initialize an array with some value using <a href="https://msdn.microsoft.com/en-us/library/aa246471%28v=vs.60%29.aspx" rel="noreferrer">memset</a>:</p>
  <pre><code>const int MAX = 1000000;
  int is_prime[MAX]
  
  memset(is_prime, 1, sizeof(is_prime))
  </code></pre>
  <p>What memset does, crudely can be described as filling the array with some value, but doing this really really fast.</p>
  <p>In go I can do <code>is_prime := make([]int, 1000000)</code>, but this will create a slice with all 0, in the similar manner I can use <code>new([1000000]int)</code>, but nothing will allow me to create an array/slice with all 1 or any other non-zero element.</p>
  <p>Of course I can use a loop to populate it with the value later, but the main purpose of <code>memset</code> is that it is way way faster than the loop.</p>
  <p>So do Go programmers have a <code>memset</code> analog (fast way of initializing array to some non-zero value)?</p>