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
- func Apply(ctx context.Context, current string) (string, error)
- func DefaultCachePath() (string, error)
- func Due(c Cache, now time.Time, interval time.Duration) bool
- func Latest(ctx context.Context) (string, error)
- func Newer(current, latest string) bool
- func PromptYesNo(r io.Reader, w io.Writer, prompt string) (bool, error)
- func Save(path string, c Cache) error
- func ShouldCheck(jsonMode, noFlag bool, env, version string) bool
- func ShouldPrompt(isTTY bool) bool
- type Cache
Constants ¶
const CheckInterval = 24 * time.Hour
CheckInterval is the minimum time between real GitHub queries.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
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 ¶
DefaultCachePath returns ~/.speed-test/update-check.json.
func Latest ¶
Latest returns the newest release version tag (e.g. "v0.2.0"), or "" if none is found.
func Newer ¶
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 ¶
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 ShouldCheck ¶
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 ¶
ShouldPrompt reports whether to interactively prompt (only on a TTY).