2020-02-10 17:27:05 -06:00
|
|
|
// Copyright 2019 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package cpu
|
|
|
|
|
|
|
|
import (
|
2020-02-25 11:22:59 -06:00
|
|
|
"encoding/binary"
|
2020-02-10 17:27:05 -06:00
|
|
|
"runtime"
|
|
|
|
)
|
|
|
|
|
|
|
|
// hostByteOrder returns binary.LittleEndian on little-endian machines and
|
|
|
|
// binary.BigEndian on big-endian machines.
|
2020-02-25 11:22:59 -06:00
|
|
|
func hostByteOrder() binary.ByteOrder {
|
2020-02-10 17:27:05 -06:00
|
|
|
switch runtime.GOARCH {
|
|
|
|
case "386", "amd64", "amd64p32",
|
|
|
|
"arm", "arm64",
|
|
|
|
"mipsle", "mips64le", "mips64p32le",
|
|
|
|
"ppc64le",
|
|
|
|
"riscv", "riscv64":
|
2020-02-25 11:22:59 -06:00
|
|
|
return binary.LittleEndian
|
2020-02-10 17:27:05 -06:00
|
|
|
case "armbe", "arm64be",
|
|
|
|
"mips", "mips64", "mips64p32",
|
|
|
|
"ppc", "ppc64",
|
|
|
|
"s390", "s390x",
|
|
|
|
"sparc", "sparc64":
|
2020-02-25 11:22:59 -06:00
|
|
|
return binary.BigEndian
|
2020-02-10 17:27:05 -06:00
|
|
|
}
|
|
|
|
panic("unknown architecture")
|
|
|
|
}
|