stripe-cli
stripe-cli copied to clipboard
feat(useragent): add Windows support for getUname() to get User-Agent.
// TODO: if there is appetite for it in the community
// add support for Windows GetSystemInfo
✅ I do have appetite for this! I’d be happy to extend the implementation to include GetSystemInfo or any additional support from the community as it becomes available or necessary.
Feature: Add Windows Support for getUname() in User Agent, similar to the existing Unix support.
This PR adds a Windows-specific implementation of the getUname() function to match the format and style used on Unix systems. It is designed to support consistent system identification for tools like Stripe CLI or other cross-platform utilities.
Summary
- Implements
getUname()for Windows systems. - Output matches Unix format:
Example:
OUTPUT "Windows DESKTOP-EGCRO4R 10.0.19045 Build 19045 x86_64
🔧 Technical Details
✅ Uses from x/sys/windows
windows.GetComputerName– gets the local hostname.windows.UTF16ToString– converts UTF-16 output.
❗ Manually defined (not in x/sys/windows)
RtlGetVersion– for accurate OS version info (fromntdll.dll).SYSTEM_INFOstruct – to get CPU architecture viaGetNativeSystemInfo.- Architecture constants like
PROCESSOR_ARCHITECTURE_AMD64,ARM64, etc.
🧱 Reason for Manual Definitions
These Windows APIs/structs are currently not exposed by
x/sys/windowsas of 2025. This PR safely and clearly defines them using proper alignment and system docs.
🔒 Safety Notes
RtlGetVersionis the officially recommended way (by Microsoft) to get OS version, unlikeGetVersionExorsyscall.GetVersion()which are deprecated or inaccurate post-Windows 8.1.- All manual structs align with Microsoft’s API layout (see
sysinfoapi.h,winnt.h).
✅ Unit Test Included
TEST RESULT PHOTOS
I am using this on a Windows machine. Please find the attached photo for reference.
- System PROOF what i am using.
- Test result after executing the code :