Documentation
¶
Overview ¶
Package update tells a person when a newer release exists. It only tells: it downloads nothing and changes nothing on this machine.
The question goes to github.com, at most once a day, and is the same one the install script asks: where does the repository's "latest release" link redirect to. That is a request for one address and a read of one header. It carries no account, no site and no identifier beyond the program's name and version, and it avoids api.github.com, whose anonymous rate limit is shared by everyone behind the same address.
Index ¶
Constants ¶
const EnvDisable = "MOODLE_CLI_NO_UPDATE_CHECK"
EnvDisable turns the check off. Anything but an explicit off counts as on, the way MOODLE_CLI_READ_ONLY does: someone who sets this at all means to stop the request, and a typo must not quietly keep sending it.
const Repository = "KoukeNeko/Moodle-CLI"
Repository is where releases are published.
Variables ¶
This section is empty.
Functions ¶
func DefaultCachePath ¶
DefaultCachePath is where the answer is kept on this machine.
Types ¶
type Checker ¶
type Checker struct {
// Current is this build's version, with or without a leading "v". A build
// that is not a release ("dev") is never told it is out of date.
Current string
// CachePath is the file that remembers the last answer. It is what keeps the
// question to once a day, so a Checker without one asks nothing.
CachePath string
// Origin is where the release pages live. Empty is github.com; a test
// points it at its own server.
Origin string
// Now is the clock. Nil is the real one.
Now func() time.Time
}
Checker asks whether a newer release exists, and remembers the answer.
func (*Checker) Newer ¶
Newer returns the latest release when it is newer than this build.
It is advisory, so nothing here can fail loudly: a network that cannot be reached, a page that answers oddly and a cache that cannot be written all mean "no news". The attempt is recorded before it is made, so a network that never answers costs one wait a day, not one per command.