elastic / go-sysinfo

go-sysinfo is a library for collecting system information.
Apache License 2.0
6 stars 88 forks source link

adds HostInfo.NativeArchitecture #200

Closed intxgo closed 8 months ago

intxgo commented 9 months ago

Adds NativeArchitecture to HostInfo to empower applications to detect if they are run in emulation.

Modern desktop operating systems ported to the ARM architecture include capabilities to run x86 applications via binary translation to ease the technological transition. This is usually fine, except for applications that rely on a specific native platform, such as for installing native drivers.

Testing

Tested in the following configurations:

ARM64 CPU

macOS

Linux

Windows

N/A as Go doesn't support GOOS=Windows GOARCH=arm64

AMD64 CPU

macOS

N/A as Rosetta 2 is not supported on Intel platform

Linux

Windows

N/A as Go doesn't support GOOS=Windows GOARCH=arm64

fearful-symmetry commented 8 months ago

So, I just commented for now, but I'm a little worried that Architecture and NativeArchitecture might be functionally the same on linux.

intxgo commented 8 months ago

Code looks fine, but I'm personally curious if we have a way to test the behavior of this under linux? On Darwin we have Rosetta, but is there some similar linux utility we're hoping to support?

Linux multiarch, that's how we run x86-64 tools in linux on Apple macbooks, etc

It's quite the contrary, we want to fail gracefully in products which cannot be run in emulation instead of giving the false impression that something is wrong with them.