Documentation
¶
Overview ¶
Package selfupdate replaces the running executable with a newer stable GitHub release. It needs nothing beyond the standard library.
A release is a tag vX.Y.Z whose assets are <Name>-<os>-<arch> for each platform and checksums.txt in sha256sum format. The new binary must print its bare X.Y.Z for --version, which is checked before anything is replaced.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrCurrent = errors.New("selfupdate: already the latest version")
ErrCurrent reports that this build already is the latest release.
Functions ¶
Types ¶
type Release ¶
type Release struct {
Version string // bare X.Y.Z
Newer bool // than Version(); a dev build treats every release as newer
// contains filtered or unexported fields
}
Release is a stable release of the repository.
type Updater ¶
type Updater struct {
Repository string // owner/name
Name string // asset prefix: releases contain <Name>-<os>-<arch>
Token string
Client *http.Client
}
Updater names the GitHub repository that publishes this program's releases. Token is optional for public repositories and is sent only to the GitHub API, never to the host that serves downloads. Client is optional.
func (Updater) Update ¶
Update installs the latest stable release over executable, which is normally the result of os.Executable. Symlinks are resolved, the download is verified against checksums.txt, the new file must print the release version for --version, and the replacement is one atomic rename. Any failure leaves the current executable untouched. It returns the installed version, or ErrCurrent.