func main(){
var chinese = "我是中国人, I am Chinese"
fmt.Println("chinese length", len(chinese))
fmt.Println("chinese word length", len([]rune(chinese)))
fmt.Println("chinese word length", utf8.RuneCountInString(chinese))
}
输出:
chinese length 31
chinese word length 19
chinese word length 19