Documentation
¶
Overview ¶
Package selfupdate updates Linux CLI executables from stable GitHub releases.
Index ¶
Constants ¶
const CheckInterval = 24 * time.Hour
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Updater ¶
type Updater struct {
Owner, Repo string
Name, Version string
Token string
// ReleaseURL overrides the latest-release endpoint, primarily for tests.
ReleaseURL string
}
Updater describes a CLI whose releases contain <Name>-linux-<arch> and checksums.txt. The executable must print its bare X.Y.Z version for --version. Tokens are optional for public repositories. Callers own environment lookup, command selection, and output; this package never restarts the program.
func (Updater) CachePath ¶ added in v0.2.0
CachePath returns the OS cache path for this CLI, or empty if unavailable.
func (Updater) Check ¶ added in v0.2.0
Check returns a newer version, or empty. Checks and failures are cached for 24 hours; errors are silent. Callers decide when a notice is appropriate. Separate concurrent processes may each perform a check on a cache miss.
func (Updater) Install ¶
Install installs the latest newer release at executablePath, resolving symlinks. It verifies SHA-256 and --version before an atomic rename. A checksum protects against corruption, not a compromised release publisher. Returns the installed version, or the current version if already up to date.