title: How to loop through a UTF-8 string in Go?
body: <p>I have a string in Chinese:</p>
  
  <pre><code>x = "你好"
  </code></pre>
  
  <p>I'd like to loop through it and do something with each character in it, something like:</p>
  
  <pre><code>for i, len := 0, len(x); i &lt; len; i++ {
      foo( x[i] ) // do sth.
  }
  </code></pre>
  
  <p>I found that <code>len(x)</code> would return <code>6</code> instead of <code>2</code>, after Google I found the method <code>RuneCountInString</code> which would return the real length of the string, but I still don't know how to loop to make <code>x[i]</code> get the right character, <code>x[0] == '你'</code> for example..</p>
  
  <p>Thanks</p>