update

package
v2.3.4 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package update provides version checking and self-updating against GitHub releases.

Index

Constants

View Source
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

func ExtractBinary(data []byte, filename string) ([]byte, error)

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

func ReplaceExecutable(newBinary []byte) error

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

func Check(currentVersion string) *Result

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

func CheckCustom(currentVersion, apiURL string, timeout time.Duration) (*Result, error)

CheckCustom queries a specific API URL for releases.

func SelfUpdate

func SelfUpdate(currentVersion string, progressFn func(string)) (*Result, error)

SelfUpdate checks for the latest version, downloads the binary asset, and updates the executable.

func SelfUpdateWithCustomURL

func SelfUpdateWithCustomURL(currentVersion, apiURL string, progressFn func(string)) (*Result, error)

SelfUpdateWithCustomURL performs a self update using a specified API URL.

Jump to

Keyboard shortcuts

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