Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoReleases indicates the repository has no releases usable for update. ErrNoReleases = errors.New("no releases found") // ErrNoAsset indicates a release was found but no downloadable asset is present. ErrNoAsset = errors.New("no downloadable asset") // ErrMissingChecksums indicates checksums or signature are missing for the release. ErrMissingChecksums = errors.New("missing checksums or signature") // ErrCurrentVersionInvalid indicates the current version string could not be parsed. ErrCurrentVersionInvalid = errors.New("could not parse current version") )
Sentinel errors for programmatic handling of update-check results.
Functions ¶
func Update ¶
Update downloads and installs the given latest release. When verify is true, it will download checksums and signature and verify them using the provided trusted public key hex strings. HTTP handling uses timeouts and proper response status checks. GITHUB_TOKEN (if set) is used for authenticated requests for the checksums/signature downloads.
Types ¶
type Release ¶
type Release struct {
Version semver.Version
AssetURL string
AssetName string
// ChecksumsURL points to the checksums.txt asset for the release (containing
// sha256 hashes for release assets). ChecksumsSigURL is the detached
// ed25519 signature (hex) for the checksums file.
ChecksumsURL string
ChecksumsSigURL string
}
Release is a minimal release descriptor used by detectLatestRelease.
type UpdateCheckResult ¶ added in v0.2.0
type UpdateCheckResult struct {
Available bool
Latest *Release
// Err is non-nil when the check resolved to a special state that callers
// may want to inspect programmatically (e.g. ErrNoAsset). Note: network/API
// errors are still returned via the function error return value.
Err error
}
UpdateCheckResult represents the outcome of checking for updates. Use the Err field for programmatic inspection of special conditions (e.g. missing assets or an unparsable current version).
func CheckForUpdates ¶
func CheckForUpdates(currentVersion, repo string) (UpdateCheckResult, error)
CheckForUpdates checks for updates and returns a structured UpdateCheckResult.
It does not return an error for normal states (such as "new release exists but missing asset"), those states are represented in UpdateCheckResult.Err. Errors are reserved for actual failures contacting the API or other unexpected failures.