update

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CachePath

func CachePath(homeDir string) string

CachePath returns the path to the update check cache file.

func CompareVersions

func CompareVersions(current, latest string) bool

CompareVersions returns true if latest is newer than current. Both should be semver-like strings (with or without 'v' prefix).

func FetchLatestVersion

func FetchLatestVersion(ctx context.Context, client *http.Client) (string, error)

FetchLatestVersion fetches the latest release tag from GitHub. Uses the provided HTTP client (allows injection for testing).

func IsCacheFresh

func IsCacheFresh(entry *CacheEntry, now time.Time) bool

IsCacheFresh returns true if the cache entry is less than cacheTTL old.

func WriteCache

func WriteCache(homeDir string, entry *CacheEntry) error

WriteCache writes the update check result to the cache file. Silently returns nil on error (cache is best-effort).

Types

type CacheEntry

type CacheEntry struct {
	CheckedAt time.Time
	Latest    string
}

CacheEntry represents the cached update check state.

func ParseCache

func ParseCache(content string) *CacheEntry

ParseCache parses cache file contents into a CacheEntry. Returns nil if the content is malformed.

func ReadCache

func ReadCache(homeDir string) *CacheEntry

ReadCache reads the cached update check result. Returns nil if the cache doesn't exist or is malformed.

type Result

type Result struct {
	Latest    string
	HasUpdate bool
}

Result holds the outcome of an update check.

func Check

func Check(homeDir, currentVersion string) *Result

Check performs the full update check flow: 1. Read cache — if fresh, use cached result 2. If stale/missing, fetch from GitHub with timeout 3. Write result to cache Returns nil if the check was skipped or failed (never errors to callers).

Jump to

Keyboard shortcuts

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