调整
LittleEndian为
BigEndian适当的
package mainimport ( "bytes" "encoding/binary" "fmt")func main() { buf := new(bytes.Buffer) source := []uint32{1, 2, 3} err := binary.Write(buf, binary.LittleEndian, source) if err != nil { fmt.Println("binary.Write failed:", err) } fmt.Printf("Enpred: % xn", buf.Bytes()) check := make([]uint32, 3) rbuf := bytes.NewReader(buf.Bytes()) err = binary.Read(rbuf, binary.LittleEndian, &check) if err != nil { fmt.Println("binary.Read failed:", err) } fmt.Printf("Depred: %vn", check)}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)