update

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 13 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 update provides self-update functionality for the Mush CLI.

It wraps the go-selfupdate library to check for and apply updates from GitHub Releases with checksum verification.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDisabled

func IsDisabled() bool

IsDisabled returns true if update checks are disabled via MUSH_UPDATE_DISABLED.

func NeedsElevation

func NeedsElevation(binaryPath string) bool

NeedsElevation returns true if the binary's parent directory is not writable.

func ReExecWithSudo

func ReExecWithSudo() error

ReExecWithSudo re-launches the current command under sudo. This replaces the current process via syscall.Exec.

func SaveState

func SaveState(s *State) error

SaveState writes the state file atomically.

Types

type Info

type Info struct {
	CurrentVersion  string `json:"currentVersion"`
	LatestVersion   string `json:"latestVersion"`
	UpdateAvailable bool   `json:"updateAvailable"`
	ReleaseURL      string `json:"releaseURL,omitempty"`

	// Release is the underlying release metadata (nil if not available).
	Release *selfupdate.Release `json:"-"`
}

Info holds the result of a version check.

type State

type State struct {
	LastCheckedAt  time.Time `json:"lastCheckedAt"`
	LatestVersion  string    `json:"latestVersion,omitempty"`
	CurrentVersion string    `json:"currentVersion,omitempty"`
	ReleaseURL     string    `json:"releaseURL,omitempty"`
}

State holds cached update check results.

func LoadState

func LoadState() (*State, error)

LoadState reads the state file. Returns zero-value State if the file doesn't exist.

func (*State) HasUpdate

func (s *State) HasUpdate(currentVersion string) bool

HasUpdate returns true if the cached latest version is newer than current.

func (*State) ShouldCheck

func (s *State) ShouldCheck() bool

ShouldCheck returns true if enough time has passed since the last check.

type Updater

type Updater struct {
	// contains filtered or unexported fields
}

Updater manages checking for and applying updates.

func NewUpdater

func NewUpdater() (*Updater, error)

NewUpdater creates a new Updater configured for GitHub Releases.

func (*Updater) Apply

func (u *Updater) Apply(ctx context.Context, release *selfupdate.Release) error

Apply downloads and installs the given release, replacing the current binary.

func (*Updater) ApplyVersion

func (u *Updater) ApplyVersion(ctx context.Context, version string) (*selfupdate.Release, error)

ApplyVersion downloads and installs a specific version.

func (*Updater) CheckLatest

func (u *Updater) CheckLatest(ctx context.Context, currentVersion string) (*Info, error)

CheckLatest checks if a newer version is available.

Jump to

Keyboard shortcuts

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