Documentation
¶
Overview ¶
Package hostinfo reads cached OS, architecture, CPU, memory, GPU and account facts of this machine
Index ¶
- Constants
- Variables
- func BatteryCategory(status BatteryStatus) string
- func ClassifyGPUVendors(vendorIDs []string) string
- func DetectContainer() bool
- func GPUClass() string
- func GoVersion() string
- func InteractiveSession() bool
- func IsContainer() bool
- func IsNvidiaN1XPCIID(pciID int) bool
- func IsTermux() bool
- func IsWSL() bool
- func ModuleVersion(path string) string
- func NativeArch() string
- func NormalizeArch(raw string) string
- func OSFamily() string
- func PinContainer(inside bool) (restore func())
- func PinGPUClass(class string) (restore func())
- func PinInteractiveSession(active bool) (restore func())
- func ProcessArch() string
- func WindowsNativeArch(wow64Native int, machine string) string
- type BatteryStatus
- type DisplayAdapter
- type GPUAdapter
Constants ¶
const ( BatteryCategoryGood = "good" BatteryCategoryWarn = "warn" BatteryCategoryBad = "bad" BatteryCategoryCritical = "critical" BatteryCategoryDim = "dim" )
Variables ¶
var ImageFileMachine = map[int]string{0x8664: "amd64", 0xAA64: "arm64", 0x014C: "x86"}
ImageFileMachine maps PE machine codes to canonical architecture names
Functions ¶
func BatteryCategory ¶
func BatteryCategory(status BatteryStatus) string
BatteryCategory buckets a reading into good, warn, bad, critical or dim for the status bar colour
func ClassifyGPUVendors ¶
ClassifyGPUVendors returns the highest priority GPU class for PCI vendor ids, none, or unknown when none were readable
func DetectContainer ¶
func DetectContainer() bool
Container markers read again on every call, the uncached probe the chmod skip policy consults
func GPUClass ¶
func GPUClass() string
GPUClass is nvidia, amd, intel, apple_silicon, none, or unknown
func GoVersion ¶
func GoVersion() string
Go release that built this binary without the go prefix, a devel build keeping its marker
func InteractiveSession ¶
func InteractiveSession() bool
InteractiveSession reports whether this process can reach an interactive user session
func IsContainer ¶
func IsContainer() bool
IsContainer reports whether this process runs inside a container
func IsNvidiaN1XPCIID ¶
IsNvidiaN1XPCIID recognizes the N1X device range packed above the NVIDIA vendor id
func ModuleVersion ¶
Version of a module linked into this binary from its build info, empty when the build lists no such module
func NativeArch ¶
func NativeArch() string
NativeArch is the machine architecture even when this process is emulated
func NormalizeArch ¶
NormalizeArch returns the canonical architecture name, unknown when unrecognized
func OSFamily ¶
func OSFamily() string
OSFamily is the platform identifier the way Python sys.platform names it
func PinContainer ¶
func PinContainer(inside bool) (restore func())
Answers every container read with inside until restore runs, simulating another host
func PinGPUClass ¶
func PinGPUClass(class string) (restore func())
Answers every GPU class read with class until restore runs, simulating another host
func PinInteractiveSession ¶
func PinInteractiveSession(active bool) (restore func())
Answers every interactive session read with active until restore runs, simulating another session
func ProcessArch ¶
func ProcessArch() string
ProcessArch is the architecture this binary was built for
func WindowsNativeArch ¶
WindowsNativeArch is IsWow64Process2's native machine, else the reported machine name
Types ¶
type BatteryStatus ¶
BatteryStatus is one battery reading, the percent clamped to a hundred and Plugged nil when unknown
func ReadBattery ¶
func ReadBattery(useCache bool) BatteryStatus
ReadBattery returns the current battery status, memoised for a few seconds when useCache is set
func (BatteryStatus) Charging ¶
func (s BatteryStatus) Charging() bool
Charging reports a battery on external power
type DisplayAdapter ¶
DisplayAdapter is one Windows display class adapter row
func ParseWindowsDisplayAdapters ¶
func ParseWindowsDisplayAdapters(rows [][3]string) []DisplayAdapter
ParseWindowsDisplayAdapters turns subkey, MatchingDeviceId and DriverDesc rows into adapters, skipping virtual ones
type GPUAdapter ¶
One graphics adapter as DXGI enumerates it
func WindowsGPUAdapters ¶
func WindowsGPUAdapters() []GPUAdapter
Every adapter DXGI enumerates in its order, empty off Windows or when DXGI cannot answer
func (GPUAdapter) MemoryBytes ¶
func (a GPUAdapter) MemoryBytes() int64
What Windows lets this adapter allocate, dedicated plus shared memory as Task Manager shows it