updates

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 18 Imported by: 0 modules, 0 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 updates checks whether a newer launcher has been released, and finds its installer so the launcher can download and run it.

Index

Constants

View Source
const MaxInstaller = 200 << 20

MaxInstaller is the largest installer accepted.

Variables

View Source
var Hosts = []string{"api.github.com", "github.com", "objects.githubusercontent.com", "release-assets.githubusercontent.com"}

Hosts are where releases and their files are fetched from: the API, then release downloads, which redirect to GitHub's file hosts.

View Source
var LatestURL = "https://api.github.com/repos/diablo2org/launcher/releases/latest"

LatestURL is the GitHub API for the newest non-prerelease release.

Functions

func Apply added in v0.3.3

func Apply(path string) error

Apply puts the downloaded AppImage in place of the running one and starts it once this one has quit (the caller quits).

func CanApply added in v0.3.3

func CanApply() bool

CanApply reports whether the launcher can replace its AppImage: run from one, in a folder this user can write to. Installed packages (.deb, .rpm) update with the system's package manager instead.

func Download

func Download(ctx context.Context, c *fetch.Client, inst *Installer, dir string, progress fetch.Progress) (string, error)

Download fetches an installer into dir, checking its size and SHA-256, and returns its path. progress may be nil.

The hash comes from the same release, so this catches a corrupted or swapped download, not a compromised release. Once installers are signed, their signature should be checked here too.

func Newer

func Newer(a, b string) bool

Newer reports whether version a is newer than b. Both are "vX.Y.Z"; anything else is never newer.

func UseSource

func UseSource(base string)

UseSource points update checks at base instead of GitHub, for testing against a local server: base/latest is the release, and its files are under base/releases/download/.

Types

type Installer

type Installer struct {
	Name   string `json:"name"`
	URL    string `json:"-"`
	Size   int64  `json:"size"`
	SHA256 string `json:"-"`
}

Installer is a release's installer, with what it must match once downloaded.

type Release

type Release struct {
	Version string `json:"version"`
	// URL is the release page.
	URL string `json:"url"`
	// Installer is what this machine updates itself from, with a known
	// hash: the installer on Windows, the .dmg on macOS and the AppImage on
	// Linux where the running launcher can replace itself (Apply). Nil when
	// there's none; then the player gets Download or the release page.
	Installer *Installer `json:"installer"`
	// Download is the package for this system that the player downloads
	// and installs themselves, where the launcher doesn't update itself
	// yet: the .dmg on macOS, the AppImage on Linux. "" if there's none.
	Download string `json:"download"`
}

Release is a newer launcher release.

func Check

func Check(ctx context.Context, c *fetch.Client, latestURL, current string) (*Release, error)

Check returns the newest release if it is newer than current, or nil. Development builds ("dev") never report an update.

Jump to

Keyboard shortcuts

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