package main import ( "bytes" "fmt" ) func main() { str := "Hello, 世界" var buf bytes.Buffer buf.Write([]byte(str)) for { r, size, err := buf.ReadRune() if err != nil { break } fmt.Printf("%c occupies %d bytes\n", r, size) } }In this example, we created a bytes.Buffer and wrote a string to it. Then we looped through the buffer using ReadRune to read one rune at a time, output its character and byte size until there were no more runes in the buffer. Package Library: This method is part of the bytes package in Go's standard library.