updatecheck

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 10 Imported by: 2 modules, 1 package

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 updatecheck reports whether a newer GitHub release of a CLI exists and how to upgrade it via the package manager that installed it. It never touches the binary — the actual upgrade is delegated to the package manager (see ADR-0005).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Checker

type Checker struct {
	Repo    string       // "owner/name"
	BaseURL string       // "" → https://api.github.com
	Client  *http.Client // nil → a client with a 5s timeout
}

Checker queries a GitHub repo's latest release.

func (Checker) CheckNewer

func (c Checker) CheckNewer(ctx context.Context, current string) (latest string, newer bool, err error)

CheckNewer returns the latest release tag for the repo and whether it is newer than current.

type Hinter

type Hinter struct {
	Repo      string           // "owner/name"
	Bin       string           // binary name: the hint label and brew/mise/scoop command
	Module    string           // `go install` target path (used only when go-installed)
	Current   string           // current version
	CacheFile string           // "" → always fetch (no cache)
	BaseURL   string           // "" → https://api.github.com (test seam)
	Client    *http.Client     // nil → default
	Now       func() time.Time // nil → time.Now (test seam)
}

Hinter prints a one-line upgrade hint when a newer release exists, fetching at most once per 24h (when CacheFile is set). Every error is swallowed — the hint must never break a normal run.

func (Hinter) Print

func (h Hinter) Print(ctx context.Context, w io.Writer)

Print writes "<bin> X available — run: <upgrade command>" to w when a newer release exists. Errors are swallowed.

type InstallMethod

type InstallMethod int

InstallMethod is how a binary was installed, inferred from its path.

const (
	Unknown InstallMethod = iota
	Homebrew
	Mise
	Scoop
	GoInstall
)

func DetectInstall

func DetectInstall() InstallMethod

DetectInstall infers how the running executable was installed by resolving its real path and matching known package-manager locations.

func (InstallMethod) UpgradeCommand

func (m InstallMethod) UpgradeCommand(bin, module string) string

UpgradeCommand returns the command to upgrade bin via this install method, or "" for Unknown (callers fall back to a generic message). module is the `go install` target path, used only for GoInstall.

Jump to

Keyboard shortcuts

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