sys.go 498 B

123456789101112131415161718192021222324
  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
  10. // ByteOrder.
  11. var NativeEndian binary.ByteOrder
  12. func init() {
  13. i := uint32(1)
  14. b := (*[4]byte)(unsafe.Pointer(&i))
  15. if b[0] == 1 {
  16. NativeEndian = binary.LittleEndian
  17. } else {
  18. NativeEndian = binary.BigEndian
  19. }
  20. }