package main import ( "fmt" "unicode/utf8" ) func main(){ var str string str="asSASA ddd dsjkdsjs dk" fmt.Printf("String %s Length: %d, Runes: %d ", str, len([]byte(str)), utf8.RuneCount([]byte(str))) }
输出结果:
$ go run firstthirdtwo.go
String asSASA ddd dsjkdsjs dk
Length: 22, Runes: 22