host package provides functions to retrieve system-level host information including hostname, uptime, boot time, platform details, and currently logged-in users.
Key Features
System Information
Retrieve comprehensive host information including OS, platform, kernel version, and virtualization details
Boot Time & Uptime
Get system boot time and uptime with optional caching
User Sessions
Query currently logged-in users and their session information
Platform Detection
Detect OS platform, family, and version information
Core Types
InfoStat
The primary struct containing comprehensive host information:UserStat
Represents a logged-in user session:Main Functions
Info()
Get comprehensive host information
BootTime()
Get system boot time in seconds since epoch
Users()
Get list of currently logged-in users
PlatformInformation()
Get platform, family, and version information
Quick Start
Context Support
All functions have context-aware variants with theWithContext suffix, allowing for cancellation and timeout control:
InfoWithContext(ctx context.Context)BootTimeWithContext(ctx context.Context)UsersWithContext(ctx context.Context)PlatformInformationWithContext(ctx context.Context)
Next Steps
Host Info
Learn about retrieving detailed host information
Boot Time
Understand boot time and uptime retrieval