Skip to content

Instantly share code, notes, and snippets.

@pinzolo
Last active May 31, 2016 04:17
Show Gist options
  • Save pinzolo/f112754435656b42445002c8d14e8487 to your computer and use it in GitHub Desktop.
Save pinzolo/f112754435656b42445002c8d14e8487 to your computer and use it in GitHub Desktop.
Get rune from string.
package main
import (
"fmt"
)
func main() {
s := "日本語"
fmt.Println(string(s[0])) // => æ
fmt.Println(string(getRuneAt(s, 0))) // => 日
}
func getRuneAt(s string, i int) rune {
rs := []rune(s)
return rs[i]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment