endian.go 301 B

1234567891011121314
  1. package nlenc
  2. import "encoding/binary"
  3. // NativeEndian returns the native byte order of this system.
  4. func NativeEndian() binary.ByteOrder {
  5. // Determine endianness by storing a uint16 in a byte slice.
  6. b := Uint16Bytes(1)
  7. if b[0] == 1 {
  8. return binary.LittleEndian
  9. }
  10. return binary.BigEndian
  11. }