update

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package update checks whether a newer netscope release is available on GitHub and reports it to the UI. The actual download+swap is handled by the GUI app (desktop/updates_darwin.go), which restarts the daemon over its unix socket after replacing the bundle — no admin prompt needed.

SHA-256 verification of downloaded release assets against the release's checksums.txt (produced by CI at package time, shasum -a 256 format).

Index

Constants

View Source
const ChecksumAsset = "checksums.txt"

ChecksumAsset is the release asset holding SHA-256 sums of the other assets (one "hex filename" line each, shasum -a 256 format).

Variables

This section is empty.

Functions

func FindChecksum added in v0.17.0

func FindChecksum(sums, name string) (digest string, ok bool)

FindChecksum extracts the SHA-256 hex digest for the named file from a checksums.txt body. Lines look like "<64-hex> <name>" (shasum also emits a "*<name>" binary-mode marker, which is accepted). Returns ok=false when the file has no entry.

func Newer

func Newer(latest, current string) bool

Newer reports whether version `latest` is strictly greater than `current` under semver (ignoring a leading "v" and any pre-release suffix). If either side is not parseable (e.g. a "dev" build), it returns false so we never nag.

func VerifyFileSHA256 added in v0.17.0

func VerifyFileSHA256(path, wantHex string) error

VerifyFileSHA256 hashes the file at path and compares it to the expected hex digest, returning a descriptive error on mismatch.

Types

type Checker

type Checker struct {
	// contains filtered or unexported fields
}

Checker periodically refreshes and caches an update Status.

func NewChecker

func NewChecker(repo, current string, interval time.Duration) *Checker

NewChecker builds a Checker. interval bounds how often GitHub is queried.

func (*Checker) Run

func (c *Checker) Run(ctx context.Context)

Run checks immediately, then on the interval, until ctx is cancelled.

func (*Checker) Status

func (c *Checker) Status() Status

Status returns the most recent cached status.

type Status

type Status struct {
	Current         string    `json:"current"`
	Latest          string    `json:"latest"`
	UpdateAvailable bool      `json:"updateAvailable"`
	URL             string    `json:"url"`         // release page (human-facing)
	AssetURL        string    `json:"assetUrl"`    // app .zip download (in-app self-update)
	ChecksumURL     string    `json:"checksumUrl"` // checksums.txt with the zip's SHA-256
	CheckedAt       time.Time `json:"checkedAt"`
}

Status is the cached result of an update check.

func Check

func Check(ctx context.Context, repo, current string) (Status, error)

Check queries the repo's latest GitHub release and compares it to current. A repo with no releases yields a non-error Status with UpdateAvailable=false.

Jump to

Keyboard shortcuts

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