-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adds HostInfo.NativeArchitecture #200
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's cool that we can detect the presence of Rosetta. I had no idea about sysctl.proc_translated
.
So, I just commented for now, but I'm a little worried that |
func NativeArchitecture() (string, error) { | ||
var processMachine, nativeMachine uint16 | ||
// the pseudo handle doesn't need to be closed | ||
var currentProcessHandle = windows.CurrentProcess() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to close this handle after we're done?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, as the explicit comment says. If you're not convinced check the manual
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, we've had issues with leaving handles open, so I'm a tad paranoid...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
Adds
NativeArchitecture
toHostInfo
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