title: Go - uint32 in for loop condition (mismatched types int and uint32)
body: <p>For the sake of type strictness I sometimes store my sizes as uint's when a size cannot be negative.  When used in for loops, I want it to look like this:</p>
  
  <pre><code>var size uint32 = 8
  for i := 0; i &lt; size; {
      n := //doesn't matter how how this value is determined
      i += n
  }
  </code></pre>
  
  <p>However, I get the following error message: <code>invalid operation: i &lt; size (mismatched types int and uint32)</code></p>
  
  <p>Rewriting the for loop to specify a type like this:</p>
  
  <pre><code>for var i uint32 = 0; i &lt; size; {
  </code></pre>
  
  <p>Yields this compiler error: <code>syntax error: var declaration not allowed in for initializer</code></p>
  
  <p>The only ways around these errors are:</p>
  
  <pre><code>for i := 0; uint32(i) &lt; size; {
  </code></pre>
  
  <p>or</p>
  
  <pre><code>var i uint32 = 0
  for i &lt; size {
  </code></pre>
  
  <p>The first on is inefficient because I am casting on every iteration and the second one is less elegant.  Is there a better way to do this?</p>