update

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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.

View Source
const Repository = "KoukeNeko/Moodle-CLI"

Repository is where releases are published.

Variables

This section is empty.

Functions

func DefaultCachePath

func DefaultCachePath() (string, error)

DefaultCachePath is where the answer is kept on this machine.

func Disabled

func Disabled(getenv func(string) string) bool

Disabled reports whether the environment says not to check: the opt-out above, or an automation that has no one to tell.

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

func (c *Checker) Newer(ctx context.Context) (Release, bool)

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.

type Release

type Release struct {
	// Tag is the version as the repository names it: "v0.4.0".
	Tag string
	// URL is the release's page, built from Tag and nothing GitHub sent.
	URL string
}

Release is a published version.

Jump to

Keyboard shortcuts

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