architecture_linux.go 472 B

123456789101112131415161718
  1. // Package platform provides helper function to get the runtime architecture
  2. // for different platforms.
  3. package platform
  4. import (
  5. "bytes"
  6. "golang.org/x/sys/unix"
  7. )
  8. // runtimeArchitecture gets the name of the current architecture (x86, x86_64, …)
  9. func runtimeArchitecture() (string, error) {
  10. utsname := &unix.Utsname{}
  11. if err := unix.Uname(utsname); err != nil {
  12. return "", err
  13. }
  14. return string(utsname.Machine[:bytes.IndexByte(utsname.Machine[:], 0)]), nil
  15. }