install

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package install detects how the running truestamp binary was installed. The detection is best-effort: it inspects the resolved executable path, Go build metadata, and environment variables. Callers use the result to decide whether `truestamp upgrade` should perform an in-place replace or print a package-manager-specific instruction.

Index

Constants

This section is empty.

Variables

View Source
var GOOS = func() string { return runtime.GOOS }

GOOS returns runtime.GOOS. Exposed as a function so tests can stub it.

Functions

func BinaryWritable

func BinaryWritable() bool

BinaryWritable reports whether the current user can write a new binary into the directory containing the running executable. Used to decide whether an Unknown install method can be handled by in-place replace.

func Executable

func Executable() string

Executable returns the resolved path (symlinks followed) of the running binary used during detection. Empty string if detection couldn't resolve.

Types

type Method

type Method int

Method is how the truestamp binary was installed.

const (
	// Unknown is used when the binary path does not match any known
	// install location and no Go build metadata points to `go install`.
	Unknown Method = iota
	// Homebrew means the binary lives under a Homebrew prefix
	// (/opt/homebrew, /usr/local/Cellar, /home/linuxbrew/.linuxbrew).
	Homebrew
	// GoInstall means the binary was produced by `go install` — detected
	// via Go build metadata and/or path under $GOBIN or $GOPATH/bin.
	GoInstall
	// InstallScript means the binary was placed by install.sh (or a
	// manual tarball extraction) into a standard user-writable path.
	InstallScript
)

func Detect

func Detect() Method

Detect classifies the running binary. Result is cached for the lifetime of the process.

func (Method) String

func (m Method) String() string

String returns a user-facing label. Zero-value Unknown prints "unknown" so version output stays readable.

func (Method) UpgradeCommand

func (m Method) UpgradeCommand() string

UpgradeCommand returns the command the user should run to upgrade this install method. Empty string for methods the upgrade command performs in-place (InstallScript, Unknown-but-writable).

Jump to

Keyboard shortcuts

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