osinfo

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package osinfo identifies the running Windows OS the way classic login scripts did — by reading a handful of registry values and classifying them — but returns one typed Info instead of a pile of ad-hoc string compares scattered across a script.

The reads are Windows-only (Detect returns ErrUnsupportedPlatform elsewhere), but the classification logic is pure and platform-independent, so the interesting decisions are unit-tested everywhere.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedPlatform = errors.New("winadmin/osinfo: only supported on Windows")

ErrUnsupportedPlatform is returned by Detect off Windows.

Functions

This section is empty.

Types

type Info

type Info struct {
	ProductName    string // e.g. "Windows 10 Pro" / "Windows Server 2019 Standard"
	EditionID      string // e.g. "Professional", "ServerStandard"
	DisplayVersion string // e.g. "22H2" (ReleaseId on older builds)
	Major, Minor   int    // e.g. 10, 0  (0 on pre-Windows-10 builds that lack the value)
	Build          int    // e.g. 22621
	UBR            int    // update build revision (the ".1702" in 10.0.22621.1702)
	Arch           string // normalized: "amd64", "x86", "arm64"
	Role           Role
	TerminalServer bool // true when this is an RDS/Citrix application host (multi-user)
}

Info is a structured description of the OS.

func Detect

func Detect() (Info, error)

Detect reads the OS information from the registry. Off Windows it returns ErrUnsupportedPlatform.

func (Info) IsDomainController

func (i Info) IsDomainController() bool

IsDomainController reports whether this box is a DC.

func (Info) IsRDSHost

func (i Info) IsRDSHost() bool

IsRDSHost reports whether this is a multi-user Remote Desktop Session Host — the modern read of the old session-host check (a server in TS application mode).

func (Info) IsServer

func (i Info) IsServer() bool

IsServer reports whether this is any server SKU (member server or DC).

func (Info) String

func (i Info) String() string

String renders a one-line human summary.

func (Info) Version

func (i Info) Version() string

Version is the dotted version string, e.g. "10.0.22621.1702".

type Role

type Role int

Role is the installation type, from the ProductType registry value.

const (
	Workstation      Role = iota // WinNT   — a client OS
	MemberServer                 // ServerNT — a server that is not a DC
	DomainController             // LanmanNT — a domain controller
)

func (Role) String

func (r Role) String() string

String renders the role.

Jump to

Keyboard shortcuts

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