version

package
v0.30.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package version provides non-blocking version checking against GitHub releases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintNotice

func PrintNotice(result *CheckResult, installCmd string) bool

PrintNotice prints an upgrade notice to stderr if a newer version is available. Returns true if a notice was printed.

Types

type CheckResult

type CheckResult struct {
	CurrentVersion string
	LatestVersion  string
	UpdateAvail    bool
}

CheckResult holds the outcome of a version comparison.

type Checker

type Checker struct {
	// contains filtered or unexported fields
}

Checker performs async version checks against GitHub releases.

func NewChecker

func NewChecker(currentVersion string, opts ...Option) *Checker

NewChecker creates a version checker for the given current version.

func (*Checker) Result

func (c *Checker) Result() *CheckResult

Result returns the check result. It blocks briefly (up to 100ms) for the background check to complete. Returns nil if the check has not finished, the current version is not parseable, or an error occurred.

func (*Checker) Run

func (c *Checker) Run(ctx context.Context)

Run starts the version check in a background goroutine. It is non-blocking.

type Option

type Option func(*Checker)

Option configures a Checker.

func WithAPIBaseURL

func WithAPIBaseURL(url string) Option

WithAPIBaseURL overrides the GitHub API base URL (for testing).

func WithCacheDir

func WithCacheDir(dir string) Option

WithCacheDir overrides the default cache directory.

func WithHTTPClient

func WithHTTPClient(c *http.Client) Option

WithHTTPClient sets a custom HTTP client (useful for testing).

func WithRepo

func WithRepo(owner, repo string) Option

WithRepo overrides the owner/repo for the release check.

Jump to

Keyboard shortcuts

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