moby/pkg/platform/architecture_unix.go
Tobias Klauser 7aeb3efcb4 Use unix.Uname instead of shelling out to uname on darwin/freebsd
Reuse the linux implementation based on Uname from golang.org/x/sys/unix
for darwin and freebsd.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2019-09-03 22:43:16 +02:00

20 lines
556 B
Go

// +build !windows
// Package platform provides helper function to get the runtime architecture
// for different platforms.
package platform // import "github.com/docker/docker/pkg/platform"
import (
"bytes"
"golang.org/x/sys/unix"
)
// runtimeArchitecture gets the name of the current architecture (x86, x86_64, i86pc, sun4v, ...)
func runtimeArchitecture() (string, error) {
utsname := &unix.Utsname{}
if err := unix.Uname(utsname); err != nil {
return "", err
}
return string(utsname.Machine[:bytes.IndexByte(utsname.Machine[:], 0)]), nil
}