Documentation
¶
Overview ¶
Package update tells the user when a newer pano release exists. It is notify-only by design (ADR 0010): at most once a day it asks GitHub's public releases endpoint for the latest tag, compares it with the running version and hands back a one-line hint — it never downloads or installs anything, so Homebrew (or go install) stays the only thing that changes the binary.
The check is skipped for development builds, in CI, without a terminal, with --json, when PANO_NO_UPDATE_CHECK or DO_NOT_TRACK is set, when [updates] check = false in config.toml, or when the binary was built with Default set to "off". The request bypasses every proxy (including pano itself) and carries nothing but pano's version in its User-Agent.
Index ¶
Constants ¶
const EnvDisable = "PANO_NO_UPDATE_CHECK"
EnvDisable turns the check off for one user or one shell.
const EnvDoNotTrack = "DO_NOT_TRACK"
EnvDoNotTrack is the cross-tool opt-out (https://donottrack.sh). An update check is not telemetry, but a user who set it does not want tools calling home on their own, so pano honours it.
const Interval = 24 * time.Hour
Interval is how long a check result is trusted before asking again.
const Repo = "OrRon/pano"
Repo is the GitHub repository whose releases are checked.
Variables ¶
var Default = "on"
Default is the build-time switch. Packagers who must not ship a version check (Debian, Fedora, …) compile it out with
-ldflags '-X github.com/orron/pano/internal/update.Default=off'
instead of patching the source.
Functions ¶
func Disabled ¶
Disabled returns why an automatic check must not run, or "" when it may. It looks at the build, the environment and the config file — everything but the terminal and the command, which the caller knows better.
func Hint ¶
Hint returns the upgrade command for the way exe was installed: a Homebrew Caskroom/Cellar path → brew, a Go bin dir → go install, anything else → the release page.
Types ¶
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
Checker runs Check in the background so a command's own work is never delayed by the network.
type Info ¶
type Info struct {
// Current is the running version, Latest the newest release tag with the
// leading "v" removed. Available is true when Latest is newer.
Current string `json:"current"`
Latest string `json:"latest"`
Available bool `json:"update_available"`
// URL is the release page; Hint the upgrade command that matches how
// this binary was installed (brew, go install, or the release page).
URL string `json:"url"`
Hint string `json:"hint"`
}
Info is the result of a check.
type Options ¶
type Options struct {
Current string // running version (cli.Version())
StatePath string // cache file; "" disables caching
Force bool // ignore a fresh cache entry
Exe string // executable path for Hint; default os.Executable()
HTTP *http.Client // default: direct (no proxy), 3 s timeout
Getenv func(string) string
Now func() time.Time
Endpoint string // default https://api.github.com/repos/<Repo>/releases/latest
Interval time.Duration // default Interval
}
Options configure a check. Zero values are filled from the environment.