updater

package
v0.0.0-...-d9135cd Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: AGPL-3.0 Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckForUpdates

func CheckForUpdates(currentVersion string, updateURL string, cmdName string) (string, error)

CheckForUpdates checks if there is a new version of the binary available and if so downloads it.

func Start

func Start(src string) string

Start checks if an update has been downloaded and if so returns the path to the binary to be executed to perform the update. If no update has been downloaded it returns an empty string.

Types

type Updater

type Updater struct {
	CurrentVersion string               // Currently running version.
	UpdateURL      string               // Base URL for API requests (json files).
	CmdName        string               // Command name is appended to the ApiURL like http://apiurl/CmdName/. This represents one binary.
	Dir            string               // Directory to store selfupdate state.
	Info           *availableUpdateInfo // Information about the available update.
}

Updater is the configuration and runtime data for doing an update.

Note that ApiURL, BinURL and DiffURL should have the same value if all files are available at the same location.

Example:

updater := &selfupdate.Updater{
	CurrentVersion: version,
	UpdateURL:      "http://updates.yourdomain.com/",
	Dir:            "update/",
	CmdName:        "myapp", // app name
}
if updater != nil {
	go updater.BackgroundRun()
}

func (*Updater) BackgroundRun

func (u *Updater) BackgroundRun() error

BackgroundRun starts the update check and apply cycle.

Jump to

Keyboard shortcuts

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