pax_global_header00006660000000000000000000000064137165376700014531gustar00rootroot0000000000000052 comment=b6b71def0850a2fbd7e6875f8e28217a48c5bcb4 native-1.0.0/000077500000000000000000000000001371653767000130155ustar00rootroot00000000000000native-1.0.0/doc.go000066400000000000000000000004461371653767000141150ustar00rootroot00000000000000// Package native provides easy access to native byte order. // // Usage: use native.Endian where you need the native binary.ByteOrder. // // Please think twice before using this package. // It can break program portability. // Native byte order is usually not the right answer. package native native-1.0.0/endian_big.go000066400000000000000000000001531371653767000154220ustar00rootroot00000000000000// +build mips mips64 ppc64 s390x package native import "encoding/binary" var Endian = binary.BigEndian native-1.0.0/endian_generic.go000066400000000000000000000011541371653767000162770ustar00rootroot00000000000000// +build !mips,!mips64,!ppc64,!s390x,!amd64,!386,!arm,!arm64,!mipsle,!mips64le,!ppc64le,!riscv64,!wasm // This file is a fallback, so that package native doesn't break // the instant the Go project adds support for a new architecture. // package native import ( "encoding/binary" "log" "runtime" "unsafe" ) var Endian binary.ByteOrder func init() { b := uint16(0xff) // one byte if *(*byte)(unsafe.Pointer(&b)) == 0 { Endian = binary.BigEndian } else { Endian = binary.LittleEndian } log.Printf("github.com/josharian/native: unrecognized arch %v (%v), please file an issue", runtime.GOARCH, Endian) } native-1.0.0/endian_little.go000066400000000000000000000002171371653767000161570ustar00rootroot00000000000000// +build amd64 386 arm arm64 mipsle mips64le ppc64le riscv64 wasm package native import "encoding/binary" var Endian = binary.LittleEndian native-1.0.0/endian_test.go000066400000000000000000000002511371653767000156370ustar00rootroot00000000000000package native_test import ( "testing" "github.com/josharian/native" ) func TestPrintEndianness(t *testing.T) { t.Logf("native endianness is %v", native.Endian) } native-1.0.0/go.mod000066400000000000000000000000541371653767000141220ustar00rootroot00000000000000module github.com/josharian/native go 1.13 native-1.0.0/license000066400000000000000000000020441371653767000143620ustar00rootroot00000000000000Copyright 2020 Josh Bleecher Snyder Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. native-1.0.0/readme.md000066400000000000000000000004551371653767000146000ustar00rootroot00000000000000Package native provides easy access to native byte order. `go get github.com/josharian/native` Usage: Use `native.Endian` where you need the native binary.ByteOrder. Please think twice before using this package. It can break program portability. Native byte order is usually not the right answer.