mirror of
https://github.com/moby/moby.git
synced 2026-07-12 18:45:06 +00:00
Functions in this package are only used internally in the daemon for the `/info` endpoint (Architecture), and as part of `stats` (NumProcs). I was not able to find external consumers, but deprecating the package first, so that we can remove / dismantle the package in a follow-up. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
32 lines
686 B
Go
32 lines
686 B
Go
package platform
|
|
|
|
import (
|
|
"context"
|
|
"sync"
|
|
|
|
"github.com/containerd/log"
|
|
)
|
|
|
|
var (
|
|
arch string
|
|
onceArch sync.Once
|
|
)
|
|
|
|
// Architecture returns the runtime architecture of the process.
|
|
//
|
|
// Unlike [runtime.GOARCH] (which refers to the compiler platform),
|
|
// Architecture refers to the running platform.
|
|
//
|
|
// For example, Architecture reports "x86_64" as architecture, even
|
|
// when running a "linux/386" compiled binary on "linux/amd64" hardware.
|
|
func Architecture() string {
|
|
onceArch.Do(func() {
|
|
var err error
|
|
arch, err = runtimeArchitecture()
|
|
if err != nil {
|
|
log.G(context.TODO()).WithError(err).Error("Could not read system architecture info")
|
|
}
|
|
})
|
|
return arch
|
|
}
|