version

package
v0.69.2 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package version holds build-time version information injected at link time.

Index

Constants

View Source
const (
	DefaultCheckInterval = time.Hour
	DefaultRepository    = "d0ugal/graith"
	DefaultHTTPTimeout   = 5 * time.Second
)

Defaults for the update check. These reproduce the historical hard-coded behaviour and back-fill any UpdateSettings field left unset.

Variables

View Source
var (
	Version   = "dev"
	CommitSHA = "unknown"
)

Functions

func IsNewer added in v0.48.0

func IsNewer(latest, current string) bool

Types

type UpdateCache added in v0.3.0

type UpdateCache struct {
	LatestVersion string    `json:"latest_version"`
	CheckedAt     time.Time `json:"checked_at"`
	// Repository records the "owner/repo" the cached release came from so a
	// fresh entry is never reused for a different repository. It was added after
	// the repository became configurable; a legacy entry without this field is
	// treated as DefaultRepository (see effectiveRepository).
	Repository string `json:"repository,omitempty"`
}

type UpdateResult added in v0.3.0

type UpdateResult struct {
	LatestVersion  string
	CurrentVersion string
}

func CheckForUpdate added in v0.3.0

func CheckForUpdate(cacheDir string, settings UpdateSettings) *UpdateResult

type UpdateSettings added in v0.69.1

type UpdateSettings struct {
	// Disabled short-circuits the check: when true, CheckForUpdate returns nil
	// without touching the cache or the network.
	Disabled bool
	// Repository is the "owner/repo" whose latest release is queried. Empty uses
	// DefaultRepository.
	Repository string
	// Interval is how long a cached result stays fresh. Non-positive uses
	// DefaultCheckInterval.
	Interval time.Duration
	// Timeout bounds the release HTTP request. Non-positive uses
	// DefaultHTTPTimeout.
	Timeout time.Duration
}

UpdateSettings configures a single CheckForUpdate call. The zero value is valid and reproduces the historical behaviour: enabled, the canonical repository, a one-hour cadence, and a five-second request timeout. This keeps the version package a leaf (it never imports config); callers translate their [updates] block into these fields.

Jump to

Keyboard shortcuts

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