Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var BaseURL = "https://api.github.com"
BaseURL is the GitHub API base URL (override in tests with httptest).
var DirOverride string
DirOverride allows tests to redirect the cache to a temp directory.
var InstallDirOverride string
InstallDirOverride allows tests to override the install directory detection.
Functions ¶
func CheckForUpdate ¶
CheckForUpdate fetches the latest release and returns the version if newer. Returns empty string if no update available or on any error.
func CompareVersions ¶
CompareVersions returns -1 if a < b, 0 if a == b, 1 if a > b.
func ParseVersion ¶
ParseVersion parses a semver string (with optional "v" prefix) into [major, minor, patch].
func ShouldCheck ¶
ShouldCheck returns true if >24h since last check and version is not "dev".
Types ¶
type Asset ¶
type Asset struct {
Name string `json:"name"`
BrowserDownloadURL string `json:"browser_download_url"`
}
Asset is a single file attached to a GitHub release.
type CheckResult ¶
type CheckResult struct {
LatestVersion string `json:"latest_version"`
CheckedAt time.Time `json:"checked_at"`
}
CheckResult is persisted between runs to throttle update checks.
type ReleaseResponse ¶
ReleaseResponse is the subset of GitHub's release JSON we need.
func FetchLatestRelease ¶
func FetchLatestRelease() (*ReleaseResponse, error)
FetchLatestRelease fetches the latest published release from GitHub. Returns nil, nil if no published release exists (404).