Documentation
¶
Overview ¶
Package update tells the user when a newer ngchat release is out. It only notices: nothing is downloaded or replaced (ADR 0011). The answer comes from the GitHub releases list, cached for a day so a chat started many times an hour costs one request, and every failure is silent, since a missed notice is harmless and a startup error over one would not be.
Index ¶
Constants ¶
const DefaultBaseURL = "https://api.github.com/repos/newgrounds-inc/ngchat-cli"
DefaultBaseURL is the GitHub API root for this repository's releases.
const Interval = 24 * time.Hour
Interval is how long a fetched answer is reused. GitHub allows 60 unauthenticated requests an hour per IP, which a shared office NAT could exhaust if every launch asked.
Variables ¶
This section is empty.
Functions ¶
func Eligible ¶
Eligible reports whether v is a version that can be compared against releases at all: a full vMAJOR.MINOR.PATCH tag. "dev", a GoReleaser snapshot ("1.0.1-next", no v), a pseudo-version and a +dirty build are local builds with no release to be behind; a shorthand like "v2" is no release tag this project cuts.
Types ¶
type Checker ¶
type Checker struct {
// BaseURL is the repository's API root, without a trailing slash.
BaseURL string
// HTTP makes the request; nil means a client with timeout.
HTTP *http.Client
// CachePath is where the last answer is kept; empty disables the
// cache, so every call fetches.
CachePath string
// UserAgent identifies the client to GitHub, which rejects requests
// without one. It must name the program, never the user.
UserAgent string
// Now is the clock; nil means time.Now.
Now func() time.Time
}
Checker finds a newer release. The zero value is not usable: main fills it through New, tests point BaseURL at an httptest server.
func New ¶
New returns a Checker against GitHub with its cache in the user's cache directory. A cache directory that cannot be resolved leaves the cache off rather than failing.