// 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 cpuimport ()// byteOrder is a subset of encoding/binary.ByteOrder.type byteOrder interface { Uint32([]byte) uint32 Uint64([]byte) uint64}type littleEndian struct{}type bigEndian struct{}func (littleEndian) ( []byte) uint32 { _ = [3] // bounds check hint to compiler; see golang.org/issue/14808returnuint32([0]) | uint32([1])<<8 | uint32([2])<<16 | uint32([3])<<24}func (littleEndian) ( []byte) uint64 { _ = [7] // bounds check hint to compiler; see golang.org/issue/14808returnuint64([0]) | uint64([1])<<8 | uint64([2])<<16 | uint64([3])<<24 |uint64([4])<<32 | uint64([5])<<40 | uint64([6])<<48 | uint64([7])<<56}func (bigEndian) ( []byte) uint32 { _ = [3] // bounds check hint to compiler; see golang.org/issue/14808returnuint32([3]) | uint32([2])<<8 | uint32([1])<<16 | uint32([0])<<24}func (bigEndian) ( []byte) uint64 { _ = [7] // bounds check hint to compiler; see golang.org/issue/14808returnuint64([7]) | uint64([6])<<8 | uint64([5])<<16 | uint64([4])<<24 |uint64([3])<<32 | uint64([2])<<40 | uint64([1])<<48 | uint64([0])<<56}// hostByteOrder returns littleEndian on little-endian machines and// bigEndian on big-endian machines.func hostByteOrder() byteOrder {switchruntime.GOARCH {case"386", "amd64", "amd64p32","alpha","arm", "arm64","loong64","mipsle", "mips64le", "mips64p32le","nios2","ppc64le","riscv", "riscv64","sh":returnlittleEndian{}case"armbe", "arm64be","m68k","mips", "mips64", "mips64p32","ppc", "ppc64","s390", "s390x","shbe","sparc", "sparc64":returnbigEndian{} }panic("unknown architecture")}
The pages are generated with Goldsv0.7.0-preview. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.