Documentation
¶
Overview ¶
Package updatecheck implements an opt-in, fail-silent "newer release available" check for the refresh CLI.
It queries the GitHub Releases API for the latest tag, compares it against the running version with a small semver comparison, and (when the local build is behind) returns a one-line upgrade hint. Results are throttled via a small JSON cache under the user config dir so the network is hit at most once per day; every failure path is silent so the check never disrupts the CLI.
Index ¶
Constants ¶
const DefaultBaseURL = "https://api.github.com/repos/dantech2000/refresh/releases/latest"
DefaultBaseURL is the GitHub Releases "latest" endpoint for this project.
Variables ¶
This section is empty.
Functions ¶
func UpgradeHint ¶
UpgradeHint returns a one-line "newer version available" message when latest is strictly newer than current, or "" otherwise (including when either is "dev"/unparseable). current/latest may be with or without a leading "v".
Types ¶
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker performs throttled, fail-silent update checks. The zero value is not usable; construct it with New.
func (*Checker) LatestTag ¶
LatestTag returns the most recent release tag, using the cached value when it is fresher than checkInterval and otherwise fetching once and updating the cache. It is fail-silent: any network/parse/cache error yields ("", nil-ish) without surfacing the error to the caller's hot path.
type Option ¶
type Option func(*Checker)
Option customizes a Checker. Tests inject a base URL, HTTP client, cache path, and clock so no real network or real home dir is touched.
func WithCachePath ¶
WithCachePath overrides the cache file path.
func WithHTTPClient ¶
WithHTTPClient overrides the HTTP client.