update

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package update checks GitHub for newer releases and can replace the running binary in place. All policy here is pure and offline; network/replace work lives in remote.go.

Index

Constants

View Source
const CheckInterval = 24 * time.Hour

CheckInterval is the minimum time between real GitHub queries.

Variables

This section is empty.

Functions

func Apply

func Apply(ctx context.Context, current string) (string, error)

Apply updates the running binary to the latest release if it is newer than current. It returns the new version on success, or ("", nil) when already up to date. The running executable is replaced atomically by go-selfupdate.

func DefaultCachePath

func DefaultCachePath() (string, error)

DefaultCachePath returns ~/.speed-test/update-check.json.

func Due

func Due(c Cache, now time.Time, interval time.Duration) bool

Due reports whether at least interval has passed since the last check.

func Latest

func Latest(ctx context.Context) (string, error)

Latest returns the newest release version tag (e.g. "v0.2.0"), or "" if none is found.

func Newer

func Newer(current, latest string) bool

Newer reports whether latest is strictly newer than current. It returns false for a "dev" build or any unparseable version (used by the passive notice).

func PromptYesNo

func PromptYesNo(r io.Reader, w io.Writer, prompt string) (bool, error)

PromptYesNo writes prompt to w and reads a yes/no answer from r. Empty or anything other than y/yes (case-insensitive) is false.

func Save

func Save(path string, c Cache) error

Save writes the cache, creating parent directories as needed.

func ShouldCheck

func ShouldCheck(jsonMode, noFlag bool, env, version string) bool

ShouldCheck reports whether the passive update check should run. It is skipped for machine output, when explicitly disabled, and for unversioned dev builds.

func ShouldPrompt

func ShouldPrompt(isTTY bool) bool

ShouldPrompt reports whether to interactively prompt (only on a TTY).

Types

type Cache

type Cache struct {
	LastCheck     time.Time `json:"last_check"`
	LatestVersion string    `json:"latest_version"`
}

Cache records the last update check, stored next to the history file.

func Load

func Load(path string) Cache

Load reads the cache. A missing or malformed file yields the zero value; this is best-effort and never returns an error.

Jump to

Keyboard shortcuts

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