2015-11-14 17:03:02 -05:00
|
|
|
// Package platform provides helper function to get the runtime architecture
|
|
|
|
// for different platforms.
|
|
|
|
package platform
|
|
|
|
|
|
|
|
import (
|
2017-10-31 05:32:03 -04:00
|
|
|
"bytes"
|
|
|
|
|
2017-05-23 10:22:32 -04:00
|
|
|
"golang.org/x/sys/unix"
|
2015-11-14 17:03:02 -05:00
|
|
|
)
|
|
|
|
|
2016-04-09 09:18:15 -04:00
|
|
|
// runtimeArchitecture gets the name of the current architecture (x86, x86_64, …)
|
2015-11-19 08:55:57 -05:00
|
|
|
func runtimeArchitecture() (string, error) {
|
2017-05-23 10:22:32 -04:00
|
|
|
utsname := &unix.Utsname{}
|
|
|
|
if err := unix.Uname(utsname); err != nil {
|
2015-11-14 17:03:02 -05:00
|
|
|
return "", err
|
|
|
|
}
|
2017-10-31 05:32:03 -04:00
|
|
|
return string(utsname.Machine[:bytes.IndexByte(utsname.Machine[:], 0)]), nil
|
2015-11-14 17:03:02 -05:00
|
|
|
}
|