sys.go 495 B

1234567891011121314151617181920212223
  1. // Copyright 2017 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package socket
  5. import (
  6. "encoding/binary"
  7. "unsafe"
  8. )
  9. // NativeEndian is the machine native endian implementation of ByteOrder.
  10. var NativeEndian binary.ByteOrder
  11. func init() {
  12. i := uint32(1)
  13. b := (*[4]byte)(unsafe.Pointer(&i))
  14. if b[0] == 1 {
  15. NativeEndian = binary.LittleEndian
  16. } else {
  17. NativeEndian = binary.BigEndian
  18. }
  19. }