hostinfo

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package hostinfo reads cached OS, architecture, CPU, memory, GPU and account facts of this machine

Index

Constants

View Source
const (
	BatteryCategoryGood     = "good"
	BatteryCategoryWarn     = "warn"
	BatteryCategoryBad      = "bad"
	BatteryCategoryCritical = "critical"
	BatteryCategoryDim      = "dim"
)

Variables

View Source
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

func ClassifyGPUVendors(vendorIDs []string) string

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

func IsNvidiaN1XPCIID(pciID int) bool

IsNvidiaN1XPCIID recognizes the N1X device range packed above the NVIDIA vendor id

func IsTermux

func IsTermux() bool

IsTermux reports whether this process runs inside Termux

func IsWSL

func IsWSL() bool

IsWSL reports whether this process runs inside WSL

func ModuleVersion

func ModuleVersion(path string) string

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

func NormalizeArch(raw string) string

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

func WindowsNativeArch(wow64Native int, machine string) string

WindowsNativeArch is IsWow64Process2's native machine, else the reported machine name

Types

type BatteryStatus

type BatteryStatus struct {
	Available bool
	Percent   *int
	Plugged   *bool
}

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

type DisplayAdapter struct {
	VendorID    string
	DeviceID    string
	Description string
}

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

type GPUAdapter struct {
	Description    string
	VendorID       uint32
	DedicatedBytes int64
	SharedBytes    int64
	Software       bool
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL