moby/pkg/platform/platform.go
Sebastiaan van Stijn 5c78cbd3be
pkg/platform: deprecate OSType in favor or runtime.GOOS
This const looks to only be there for "convenience", or _possibly_ was created
with future normalization or special handling in mind.

In either case, currently it is just a direct copy (alias) for runtime.GOOS,
and defining our own type for this gives the impression that it's more than
that. It's only used in a single place, and there's no external consumers, so
let's deprecate this const, and use runtime.GOOS instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-08 14:57:33 +02:00

32 lines
924 B
Go

// Package platform provides helper function to get the runtime architecture
// for different platforms.
package platform // import "github.com/docker/docker/pkg/platform"
import (
"runtime"
"github.com/sirupsen/logrus"
)
// Architecture holds 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.
var Architecture string
// OSType holds the runtime operating system type of the process. It is
// an alias for [runtime.GOOS].
//
// Deprecated: use [runtime.GOOS] instead.
const OSType = runtime.GOOS
func init() {
var err error
Architecture, err = runtimeArchitecture()
if err != nil {
logrus.WithError(err).Error("Could not read system architecture info")
}
}