Documentation
¶
Overview ¶
Package update provides version checking and self-updating against GitHub releases.
Index ¶
- Constants
- func ExtractBinary(data []byte, filename string) ([]byte, error)
- func FindMatchingAsset(assets []githubAsset, goos, goarch string) *githubAsset
- func ReplaceExecutable(newBinary []byte) error
- type Result
- func Check(currentVersion string) *Result
- func CheckCustom(currentVersion, apiURL string, timeout time.Duration) (*Result, error)
- func SelfUpdate(currentVersion string, progressFn func(string)) (*Result, error)
- func SelfUpdateWithCustomURL(currentVersion, apiURL string, progressFn func(string)) (*Result, error)
Constants ¶
const ( // Owner and repository on GitHub. RepoOwner = "lleontor705" RepoName = "cortex" // Default HTTP timeout for metadata queries. RequestTimeout = 5 * time.Second // Timeout for binary downloads. DownloadTimeout = 60 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func ExtractBinary ¶
ExtractBinary extracts the cortex executable from a zip, tar.gz, or raw binary payload.
func FindMatchingAsset ¶
func FindMatchingAsset(assets []githubAsset, goos, goarch string) *githubAsset
FindMatchingAsset finds the release asset matching the target OS and Architecture.
func ReplaceExecutable ¶
ReplaceExecutable safely replaces the current running binary with the new binary.
Types ¶
type Result ¶
type Result struct {
Current string
Latest string // latest release tag (e.g. "v0.4.0")
UpdateURL string // URL to the release page
ReleaseNotes string
IsNewer bool
AssetURL string
AssetName string
}
Result holds the outcome of a version check.
func Check ¶
Check queries the GitHub releases API and returns a Result when a newer version is available. Returns nil when the current version is up-to-date or when the check cannot be performed (network error, dev build, etc.).
func CheckCustom ¶
CheckCustom queries a specific API URL for releases.
func SelfUpdate ¶
SelfUpdate checks for the latest version, downloads the binary asset, and updates the executable.