platform

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 8 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 sshmgr 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 sshmgr 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 StdinIsTerminal

func StdinIsTerminal() bool

StdinIsTerminal reports whether standard input is a terminal.

Types

This section is empty.

Jump to

Keyboard shortcuts

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