Documentation
¶
Overview ¶
Package platform provides OS / package-manager detection and the small set of privileged and unprivileged host operations the CLI relies on.
Index ¶
- func Dispatch(mac, linux func() error) error
- func Has(name string) bool
- func InstallPackage(pkg string) error
- func IsActiveService(unit string) bool
- func Output(name string, args ...string) (string, error)
- func RemoveFilePrivileged(path string) error
- func Run(name string, args ...string) error
- func Sudo(args ...string) error
- func SudoPrime(reason string) error
- func WriteFilePrivileged(path string, content []byte, mode os.FileMode) error
- type OS
- type PackageManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dispatch ¶
Dispatch runs the handler matching the current OS, erroring on unsupported platforms. It is the single place per-OS behavior branches.
func InstallPackage ¶
InstallPackage installs a package using the detected package manager.
func IsActiveService ¶
IsActiveService reports whether a systemd unit is active (Linux only).
func RemoveFilePrivileged ¶
RemoveFilePrivileged removes a root-owned file, ignoring a missing file.
func Sudo ¶
Sudo runs a command with elevated privileges, prompting once if needed. When already running as root it executes the command directly.
Types ¶
type PackageManager ¶
type PackageManager string
PackageManager identifies a supported package manager.
const ( // Brew is Homebrew (macOS). Brew PackageManager = "brew" // Apt is APT (Ubuntu/Debian). Apt PackageManager = "apt" )
func DetectPackageManager ¶
func DetectPackageManager() (PackageManager, error)
DetectPackageManager returns the available package manager for the host.