本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
734B

  1. // Copyright 2019 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. package cpu
  5. import (
  6. "encoding/binary"
  7. "runtime"
  8. )
  9. // hostByteOrder returns binary.LittleEndian on little-endian machines and
  10. // binary.BigEndian on big-endian machines.
  11. func hostByteOrder() binary.ByteOrder {
  12. switch runtime.GOARCH {
  13. case "386", "amd64", "amd64p32",
  14. "arm", "arm64",
  15. "mipsle", "mips64le", "mips64p32le",
  16. "ppc64le",
  17. "riscv", "riscv64":
  18. return binary.LittleEndian
  19. case "armbe", "arm64be",
  20. "mips", "mips64", "mips64p32",
  21. "ppc", "ppc64",
  22. "s390", "s390x",
  23. "sparc", "sparc64":
  24. return binary.BigEndian
  25. }
  26. panic("unknown architecture")
  27. }
上海开阖软件有限公司 沪ICP备12045867号-1