architecture_unix.go 488 B

1234567891011121314151617181920
  1. // +build freebsd darwin
  2. // Package platform provides helper function to get the runtime architecture
  3. // for different platforms.
  4. package platform
  5. import (
  6. "os/exec"
  7. "strings"
  8. )
  9. // runtimeArchitecture gets the name of the current architecture (x86, x86_64, i86pc, sun4v, ...)
  10. func runtimeArchitecture() (string, error) {
  11. cmd := exec.Command("/usr/bin/uname", "-m")
  12. machine, err := cmd.Output()
  13. if err != nil {
  14. return "", err
  15. }
  16. return strings.TrimSpace(string(machine)), nil
  17. }