platform

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 1 Imported by: 0 modules, 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 platform is how a collector picks its variant: Detect is the host's family, as pkg/gohai/family names it, and a test swaps it to force any branch without reading the host.

Index

Constants

This section is empty.

Variables

View Source
var Detect = family.Detect

Detect returns the host's family: darwin on macOS, a family such as debian, rhel, fedora or amazon on Linux, the platform itself for a Linux host without a family, or "" when the host could not be read. Collectors dispatch on it:

switch platform.Detect() {
case family.Darwin: return NewDarwin()
case family.Debian: return NewDebian()
default:            return NewLinux()
}

Tests override it:

orig := platform.Detect
defer func() { platform.Detect = orig }()
platform.Detect = func() string { return "darwin" }

Functions

func IsDarwin

func IsDarwin() bool

IsDarwin reports whether the host is macOS.

func IsLinux

func IsLinux() bool

IsLinux reports whether the host is any Linux distribution. For collectors that do the same thing on each one.

Types

This section is empty.

Jump to

Keyboard shortcuts

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