update

package
v1.0.0-rc.13 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 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 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

View Source
const DefaultBaseURL = "https://api.github.com/repos/newgrounds-inc/ngchat-cli"

DefaultBaseURL is the GitHub API root for this repository's releases.

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

func Eligible(v string) bool

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

func New(current string) Checker

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.

func (Checker) Newer

func (c Checker) Newer(ctx context.Context, current string) string

Newer returns the newest release tag above current, or "" when there is none or it could not be determined. A prerelease build (an rc) is compared against prereleases too, so an rc tester hears of the next rc; a stable build only ever hears of stable releases.

Jump to

Keyboard shortcuts

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