os

package
v0.3.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: 6 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 os is the os behavior: the operating system of the host, its distribution and version.

Index

Constants

This section is empty.

Variables

View Source
var Behavior = behavior.Register(behavior.Define(
	"os", "Get the operating system of target hosts",
	behavior.Title("OS"),
	behavior.Node,
	behavior.API,
	behavior.Area(area.Node),
	behavior.CLI,

	behavior.Platform(behavior.PlatformLinux, newReader),
	behavior.Platform(behavior.PlatformDarwin, newReader),
	behavior.RunsOnPlatform(behavior.PlatformDarwin, "sw_vers"),
	behavior.Read("get", Get).
		Describe("Get the operating system of the host").
		Explain("Reads the distribution and its version: the ID and VERSION_ID of "+
			"/etc/os-release on Linux, and darwin with the ProductVersion of sw_vers on "+
			"macOS, such as darwin 15.5.").
		Example("An Ubuntu host", GetInput{},
			Entry{OSInfo: Release{Distribution: "ubuntu", Version: "24.04"}},
			behavior.OnPlatform(behavior.PlatformLinux),
			behavior.Exists("/etc/os-release", "NAME=\"Ubuntu\"\nID=ubuntu\nVERSION_ID=\"24.04\"\n"),
		).
		Example("A Mac", GetInput{},
			Entry{OSInfo: Release{Distribution: "darwin", Version: "15.5"}},
			behavior.OnPlatform(behavior.PlatformDarwin),
			behavior.Prints("sw_vers", "ProductName:\t\tmacOS\nProductVersion:\t\t15.5\nBuildVersion:\t\t24F74\n"),
		),
))

Behavior is the os definition.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	OSInfo Release `json:"os_info" doc:"The operating system"`
}

Entry is the host's operating system.

func Get

func Get(
	ctx context.Context,
	p Provider,
	_ GetInput,
) (Entry, error)

Get is the host's operating system.

type GetInput

type GetInput struct{}

GetInput is get's input, which has none.

type Provider

type Provider interface {
	Release(ctx context.Context) (Release, error)
}

Provider is what each platform implements: the operating system.

type Release

type Release struct {
	Distribution string `json:"distribution" doc:"The distribution, such as ubuntu, or darwin"`
	Version      string `json:"version"      doc:"The version of the distribution, such as 24.04"`
}

Release is a distribution and its version.

Directories

Path Synopsis
Package mocks holds the generated double of the os provider, for the methods' tests.
Package mocks holds the generated double of the os provider, for the methods' tests.

Jump to

Keyboard shortcuts

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