selfupdate

package
v0.12.4 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 12 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Asset

type Asset struct {
	Name               string `json:"name"`
	BrowserDownloadURL string `json:"browser_download_url"`
}

Asset is a single file attached to a GitHub release.

type Option

type Option func(*Updater)

Option configures an Updater.

func WithLatestURL

func WithLatestURL(url string) Option

WithLatestURL overrides the GitHub Releases API endpoint. Intended for tests.

type Release

type Release struct {
	TagName string  `json:"tag_name"`
	Assets  []Asset `json:"assets"`
}

Release is the subset of the GitHub Releases API response that heraut uses.

type Updater

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

Updater checks for and performs heraut self-updates.

func New

func New(currentVersion string, opts ...Option) *Updater

New constructs an Updater. currentVersion should be the build-time version (e.g. "v1.2.3" or "dev"). Use WithLatestURL to override the API endpoint in tests.

func (*Updater) Check

func (u *Updater) Check(ctx context.Context) (string, bool, error)

Check fetches the latest release and returns (latestTag, updateAvailable, error). It always fetches — it does not use the 24 h cache.

func (*Updater) Do

func (u *Updater) Do(ctx context.Context, w io.Writer) error

Do performs the full self-update: fetch → find asset → download → verify SHA-256 → chmod → atomic replace.

func (*Updater) Hint

func (u *Updater) Hint(ctx context.Context, w io.Writer)

Hint checks (with 24 h caching) whether an update is available and prints a hint line to w if so. Errors are silently swallowed — the hint must never affect a command's exit code. ctx should carry a short timeout (≈500 ms).

Jump to

Keyboard shortcuts

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