title: Skipping ahead n codepoints while iterating through a unicode string in Go
body: <p>In Go, iterating over a string using </p>
  
  <pre><code>for i := 0; i &lt; len(myString); i++{ 
      doSomething(myString[i])
  }
  </code></pre>
  
  <p>only accesses individual bytes in the string, whereas iterating over a string via</p>
  
  <pre><code>for i, c := range myString{ 
      doSomething(c)
  }
  </code></pre>
  
  <p>iterates over individual Unicode codepoints (called<code>rune</code>s in Go), which may span multiple bytes.</p>
  
  <p>My question is: how does one go about jumping ahead while iterating over a string with <code>range Mystring</code>? <code>continue</code> can jump ahead by one unicode codepoint, but it's not possible to just do <code>i += 3</code> for instance if you want to jump ahead three codepoints. So what would be the most idiomatic way to advance forward by n codepoints?</p>
  
  <p>I <a href="https://groups.google.com/forum/#!topic/golang-nuts/iDlasF6q_i8" rel="nofollow">asked this question</a> on the golang nuts mailing list, and it was answered, courtesy of some of the helpful folks on the list. Someone messaged me however suggesting I create a self-answered question on Stack Overflow for this, to save the next person with the same issue some trouble. That's what this is.</p>