osdetect

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package osdetect provides operating system detection and information

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPackageInstallCommand

func GetPackageInstallCommand(packageName string, info *Info) string

GetPackageInstallCommand returns the command to install a package

func GetSSHConfigPath

func GetSSHConfigPath(info *Info) string

GetSSHConfigPath returns the SSH config file path

func GetServiceRestartCommand

func GetServiceRestartCommand(serviceName string, info *Info) string

GetServiceRestartCommand returns the command to restart a service

func GetUserHomeDir

func GetUserHomeDir(username string, info *Info) string

GetUserHomeDir returns the home directory path based on OS

Types

type DistroType

type DistroType string

DistroType represents the distribution type

const (
	// Debian represents Debian-based distributions (Debian, Ubuntu, etc.)
	Debian DistroType = "debian"
	// RedHat represents Red Hat-based distributions (RHEL, CentOS, Fedora, etc.)
	RedHat DistroType = "redhat"
	// SUSE represents SUSE-based distributions (SUSE, openSUSE, etc.)
	SUSE DistroType = "suse"
	// Arch represents Arch-based distributions (Arch Linux, Manjaro, etc.)
	Arch DistroType = "arch"
	// Generic represents a generic Linux distribution
	Generic DistroType = "generic"
	// MacOS represents macOS
	MacOS DistroType = "macos"
	// UnknownDistro represents an unknown distribution
	UnknownDistro DistroType = "unknown"
)

type Info

type Info struct {
	// Type is the operating system type (Linux, Darwin, etc.)
	Type OSType
	// Distro is the distribution type (Debian, RedHat, MacOS, etc.)
	Distro DistroType
	// Version is the operating system version
	Version string
	// PlatformID is the platform identifier
	PlatformID string
	// PackageManager is the package manager type
	PackageManager PackageManager
}

Info contains information about the operating system

func Detect

func Detect() (*Info, error)

Detect detects the operating system and returns Info

type OSType

type OSType string

OSType represents the type of operating system

const (
	// Linux represents Linux operating systems
	Linux OSType = "linux"
	// Darwin represents macOS operating systems
	Darwin OSType = "darwin"
	// Unknown represents an unknown operating system
	Unknown OSType = "unknown"
)

type PackageManager

type PackageManager string

PackageManager represents the package manager type

const (
	// APT represents the APT package manager (Debian, Ubuntu, etc.)
	APT PackageManager = "apt"
	// DNF represents the DNF package manager (Fedora, etc.)
	DNF PackageManager = "dnf"
	// YUM represents the YUM package manager (RHEL, CentOS, etc.)
	YUM PackageManager = "yum"
	// Zypper represents the Zypper package manager (SUSE, openSUSE, etc.)
	Zypper PackageManager = "zypper"
	// Pacman represents the Pacman package manager (Arch Linux, Manjaro, etc.)
	Pacman PackageManager = "pacman"
	// Brew represents the Homebrew package manager (macOS)
	Brew PackageManager = "brew"
	// UnknownPM represents an unknown package manager
	UnknownPM PackageManager = "unknown"
)

Jump to

Keyboard shortcuts

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