architecture_unix.go 556 B

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