慕神8447489
不确定这是否是您想要的:package mainimport ( "fmt" "log" "strings")func main() { s := "Hello world" r := strings.NewReader(s) buf := make([]byte, 100) i, err := r.Read(buf) if err != nil { log.Fatal(err) } fmt.Println("length string:", len(s)) fmt.Println("bytes read:", i) fmt.Println(buf)}输出:length string: 11bytes read: 11[72 101 108 108 111 32 119 111 114 108 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]