...

Source file src/github.com/josharian/native/endian_generic.go

Documentation: github.com/josharian/native

     1  //go:build !mips && !mips64 && !ppc64 && !s390x && !amd64 && !386 && !arm && !arm64 && !loong64 && !mipsle && !mips64le && !ppc64le && !riscv64 && !wasm
     2  // +build !mips,!mips64,!ppc64,!s390x,!amd64,!386,!arm,!arm64,!loong64,!mipsle,!mips64le,!ppc64le,!riscv64,!wasm
     3  
     4  // This file is a fallback, so that package native doesn't break
     5  // the instant the Go project adds support for a new architecture.
     6  //
     7  
     8  package native
     9  
    10  import (
    11  	"encoding/binary"
    12  	"log"
    13  	"runtime"
    14  	"unsafe"
    15  )
    16  
    17  var Endian binary.ByteOrder
    18  
    19  var IsBigEndian bool
    20  
    21  func init() {
    22  	b := uint16(0xff) // one byte
    23  	if *(*byte)(unsafe.Pointer(&b)) == 0 {
    24  		Endian = binary.BigEndian
    25  		IsBigEndian = true
    26  	} else {
    27  		Endian = binary.LittleEndian
    28  		IsBigEndian = false
    29  	}
    30  	log.Printf("github.com/josharian/native: unrecognized arch %v (%v), please file an issue", runtime.GOARCH, Endian)
    31  }
    32  

View as plain text