github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/pkg/platform/architecture_unix.go (about)

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