platform

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 12 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 isolates the OS-specific behaviour authama needs, so the rest of the tree can stay free of runtime.GOOS branches: terminal handling for reading secrets without echoing them (here), and the OS predicates every other package asks its questions through (os.go).

The one deliberate exception is util/desktop, which dispatches to a different notification backend per OS. That is a self-contained implementation choice rather than a predicate leaking across the tree, so it keeps its own switch.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotATerminal = errors.New("standard input is not a terminal")

ErrNotATerminal is returned by ReadSecret when standard input is not a terminal, so callers can fall back to reading a piped line instead.

Functions

func EmitUseKeychain

func EmitUseKeychain() bool

EmitUseKeychain reports whether the rendered ssh config should carry UseKeychain.

It is an Apple extension: ssh on macOS reads a key's passphrase from the login keychain instead of prompting. OpenSSH elsewhere does not know the keyword, and an unknown keyword is a hard parse error for the whole file - which is why the renderer also pins `IgnoreUnknown UseKeychain`, and why this has to be decided per machine rather than baked into the manifest.

func FirstClass

func FirstClass() bool

FirstClass reports whether this OS is one authama is tested on. Elsewhere it still builds and mostly works, but the platform layer falls back to generic behaviour and preflight says so.

func IsLinux

func IsLinux() bool

IsLinux reports whether this is Linux.

func IsMacOS

func IsMacOS() bool

IsMacOS reports whether this is macOS.

func IsWindows

func IsWindows() bool

IsWindows reports whether this is Windows.

func OSName

func OSName() string

OSName is the GOOS token plus its human name, for display.

func ReadLine

func ReadLine(f io.Reader) (string, error)

ReadLine consumes a single line, one byte at a time. A buffered reader would swallow whatever follows the newline, which matters here because callers read a second line to confirm a passphrase.

func ReadSecret

func ReadSecret(prompt string) (string, error)

ReadSecret prompts on stderr and reads one line with terminal echo disabled. The previous terminal state is restored before returning, including when the user interrupts the prompt, so a cancelled read cannot leave the terminal unable to echo.

func StderrIsTerminal added in v0.1.6

func StderrIsTerminal() bool

StderrIsTerminal reports whether standard error is a terminal: where a progress line may be drawn without ending up in a log or a pipe.

func StdinIsTerminal

func StdinIsTerminal() bool

StdinIsTerminal reports whether standard input is a terminal.

Types

type SystemInfo added in v0.1.6

type SystemInfo struct {
	OS        string // "macOS", "Ubuntu", "Windows 11 Pro"
	OSVersion string // "26.1", "24.04.3 LTS (Noble Numbat)", "24H2"
	OSBuild   string // "25B78", "26100.4652"
	Kernel    string // "Darwin 25.1.0", "Linux 6.8.0-51-generic"
	Arch      string // runtime.GOARCH: "arm64", "amd64"
	Hostname  string
	Model     string // "MacBookPro18,3", "ThinkPad X1 Carbon Gen 11"
	Vendor    string // "Apple", "LENOVO"
	CPU       string // "Apple M1 Pro", "Intel(R) Core(TM) i7-1365U"
	Cores     int    // physical cores, when known
	Threads   int    // logical processors (runtime.NumCPU)
	PerfCores int    // Apple silicon: performance cores
	EffCores  int    // Apple silicon: efficiency cores
	Memory    uint64 // total physical memory, bytes
	Booted    time.Time
}

SystemInfo describes the computer authama runs on, for the About page. Every field is best effort: what this OS does not expose, or refuses to say, is left empty (zero), and nothing here ever fails.

func System added in v0.1.6

func System() SystemInfo

System gathers SystemInfo for this computer. It reads the kernel and the OS's own records directly (sysctl, /proc, the registry) and runs no commands, so it is quick enough to call per request.

func (SystemInfo) Uptime added in v0.1.6

func (s SystemInfo) Uptime() time.Duration

Uptime is how long the computer has been up, rounded to the minute; zero when the boot time is unknown.

Jump to

Keyboard shortcuts

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