sys.go raw

   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  
   5  package socket
   6  
   7  import (
   8  	"encoding/binary"
   9  	"unsafe"
  10  )
  11  
  12  // NativeEndian is the machine native endian implementation of ByteOrder.
  13  var NativeEndian binary.ByteOrder
  14  
  15  func init() {
  16  	i := uint32(1)
  17  	b := (*[4]byte)(unsafe.Pointer(&i))
  18  	if b[0] == 1 {
  19  		NativeEndian = binary.LittleEndian
  20  	} else {
  21  		NativeEndian = binary.BigEndian
  22  	}
  23  }
  24