updater

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 10 Imported by: 3 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package updater keeps an app up to date the way its platform does. On direct macOS and Windows builds, Sparkle and WinSparkle, which nsgo build bundles when nsgo.yaml configures updates, read the app's appcast on their own schedule, download a newer release, verify its EdDSA signature, install it and restart the app. Linux and direct Android builds read the same appcast and install its verified package after confirmation. Apple App Store builds offer their store page; Google Play handles a manual check with its native update flow.

Index

Constants

View Source
const (
	// PhaseIdle says no update is downloading or installing.
	PhaseIdle = core.UpdateIdle
	// PhaseDownloading says an update package is streaming to disk.
	PhaseDownloading = core.UpdateDownloading
	// PhaseInstalling says the verified package is being installed.
	PhaseInstalling = core.UpdateInstalling
)
View Source
const (
	ManagedUnavailable = core.UpdaterUnavailable
	ManagedSelf        = core.UpdaterSelf
	ManagedPage        = core.UpdaterPage
	ManagedDevelopment = core.UpdaterDevelopment
	ManagedChannel     = core.UpdaterChannel
	ManagedStore       = core.UpdaterStore
)

Variables

This section is empty.

Functions

func Check

func Check(cx *core.Scope)

Check checks for a newer version now, as a Check for Updates… item does, and shows what it finds: on direct macOS and Windows in Sparkle's and WinSparkle's windows, on Linux and direct Android an alert that installs the signed package after confirmation, on Google Play its native update flow, elsewhere an alert that offers to open the newer version's page, says the app is up to date, or says the check failed.

func CheckDaily

func CheckDaily(cx *core.Scope)

CheckDaily checks in the background, as CheckInBackground does, unless it has within the last day, so a newer version is offered once a day rather than at every start. Sparkle and WinSparkle keep such a schedule of their own; on Linux, direct Android and Apple App Store builds nsgo.Run calls CheckDaily as the app starts and as the user comes back to it when nsgo.yaml's updates.automatic is on. A check that failed, as one offline does, is tried again an hour later.

func CheckInBackground

func CheckInBackground(cx *core.Scope)

CheckInBackground checks without showing anything unless it finds a newer version, as the platforms' scheduled checks do.

func Download

func Download(ctx context.Context, update core.UpdateCheck, dir string, progress func(DownloadProgress)) (string, error)

Download streams an update's signed package directly to a temporary file in dir. It verifies size, SHA-256 and Ed25519 signature from the streamed file before making it visible, removing partial or invalid files on error.

func Install

func Install(cx *core.Scope, path string, done func(error))

Install hands a verified update package to the platform's installer. Linux reports when its package manager exits. Android reports when its system installer opens. The callback runs on the app's graph goroutine.

func SetAutomaticChecks

func SetAutomaticChecks(cx *core.Scope, on bool)

SetAutomaticChecks persists the user's choice. Native updaters own their preferences; the daily scheduler on Linux, Android and iOS uses its own partition.

func SetAutomaticDownloads

func SetAutomaticDownloads(cx *core.Scope, on bool)

SetAutomaticDownloads changes Sparkle's persisted choice on macOS. It is a no-op on platforms with no automatic-download setting.

Types

type Capability

type Capability struct {
	Managed Managed
	Store   string
}

Capability describes how this copy updates. Store names its installer when ManagedStore.

func CapabilityOf

func CapabilityOf(cx *core.Scope) Capability

CapabilityOf reports how this copy updates, synchronously and without network I/O.

type DownloadProgress

type DownloadProgress struct {
	Loaded, Total int64
}

DownloadProgress reports bytes written while an update is downloaded.

type Managed

type Managed = core.UpdaterManaged

Managed identifies who updates an installed copy, without checking a feed.

type Phase

type Phase = core.UpdatePhase

Phase is what an in-app update is doing on Linux and Android.

type State

type State struct {
	Capability                          Capability
	AutomaticChecks, AutomaticDownloads bool
	Available, Notes                    string
	LastCheck                           time.Time
	Phase                               Phase
	Loaded, Total                       int64
}

State is the updater's latest knowledge. Reading Status in a binding tracks changes. AutomaticDownloads is supported only by Sparkle on macOS. Phase, Loaded and Total follow an in-app update that downloads and installs on Linux and Android.

func Status

func Status(cx *core.Scope) State

Status returns tracked state and preferences, without checking for updates.

func (State) Fraction

func (s State) Fraction() float64

Fraction is the download's progress from 0 to 1, or 0 when Total is unknown or no bytes have arrived yet.

Directories

Path Synopsis
Package locales says the updater's words: its alerts where the platform's updater has no windows of its own.
Package locales says the updater's words: its alerts where the platform's updater has no windows of its own.

Jump to

Keyboard shortcuts

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