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 ¶
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
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.
Click to show internal directories.
Click to hide internal directories.