title: How to generate a fixed length random number in Go?
body: <p>What is the fastest and simplest way to generate fixed length random numbers in Go? </p>
  
  <p>Say to generate 8-digits long numbers, the problem with <code>rand.Intn(100000000)</code> is that the result might be far less than 8-digits, and padding it with leading zeros doesn't look like a good answer to me.</p>
  
  <p>I.e., I care about the the quality of the randomness more in the sense of its length. So I'm thinking, for this specific problem, would the following be the fastest and simplest way to do it? </p>
  
  <pre><code>99999999 - rand.Int63n(90000000)
  </code></pre>
  
  <p>I.e., I guess <code>Int63n</code> might be better for my case than <code>Intn</code>. Is it ture, or it is only a wishful thinking? Regarding randomness of the full 8-digits, would the two be the same, or there is really one better than the other? </p>
  
  <p>Finally, any better way than above? </p>
  
  <p><strong>UPDATE:</strong> </p>
  
  <p>Please do not provide <code>low + rand(hi-low)</code> as the answer, as everyone knows that. It is equivalent of what I'm doing now, and it doesn't answer my real question, <em>"Regarding randomness of the full 8-digits, would the two be the same, or there is really one better than the other? "</em></p>
  
  <p>If nobody can answer that, I'll plot a 2-D scatter plot between the two and find out myself...</p>
  
  <p>Thanks</p>