ByteOrder (Get) in Go

Posted by GoDoc
Public (Editable by Users)

A ByteOrder specifies how to convert byte sequences into 16-, 32-, or 64-bit unsigned integers.

Go
Edit
package main

import (
	"encoding/binary"
	"fmt"
)

func main() {
	b := []byte{0xe8, 0x03, 0xd0, 0x07}
	x1 := binary.LittleEndian.Uint16(b[0:])
	x2 := binary.LittleEndian.Uint16(b[2:])
	fmt.Printf("%#04x %#04x\n", x1, x2)
}