selfupdate

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package selfupdate downloads and installs javaup releases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProgressEvent added in v0.4.0

type ProgressEvent struct {
	Stage      ProgressStage
	Current    string
	Latest     string
	Name       string
	URL        string
	Downloaded int64
	Total      int64
}

ProgressEvent describes one observable point in the self-update process.

type ProgressFunc added in v0.4.0

type ProgressFunc func(ProgressEvent)

ProgressFunc receives self-update progress events.

type ProgressStage added in v0.4.0

type ProgressStage string

ProgressStage identifies a visible phase of the self-update process.

const (
	// ProgressChecking reports that the latest release is being queried.
	ProgressChecking ProgressStage = "checking"
	// ProgressAvailable reports the version transition that will be installed.
	ProgressAvailable ProgressStage = "available"
	// ProgressFetchingChecksums reports that the release checksum list is being fetched.
	ProgressFetchingChecksums ProgressStage = "fetching-checksums"
	// ProgressConnecting reports that the release archive request is being established.
	ProgressConnecting ProgressStage = "connecting"
	// ProgressDownloading reports release archive download progress.
	ProgressDownloading ProgressStage = "downloading"
	// ProgressVerifying reports that the release checksum is being verified.
	ProgressVerifying ProgressStage = "verifying"
	// ProgressExtracting reports that the release executable is being extracted.
	ProgressExtracting ProgressStage = "extracting"
	// ProgressInstalling reports that the downloaded release is being installed.
	ProgressInstalling ProgressStage = "installing"
)

type Result

type Result struct {
	Current string
	Latest  string
	Updated bool
	Pending bool
}

Result describes the outcome of an update check or installation.

type Updater

type Updater struct {
	CurrentVersion string
	HTTPClient     *http.Client
	APIBase        string
	ReleaseBase    string
	GOOS           string
	GOARCH         string
	ExecutablePath string
	// contains filtered or unexported fields
}

Updater checks GitHub Releases and replaces the current executable.

func New

func New(currentVersion string) *Updater

New returns an updater configured for the official javaup repository.

func (*Updater) Check

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

Check reports whether a newer release is available without downloading it.

func (*Updater) Update

func (u *Updater) Update(ctx context.Context) (Result, error)

Update downloads, verifies, and installs the latest release when it is newer.

func (*Updater) UpdateWithProgress added in v0.4.0

func (u *Updater) UpdateWithProgress(ctx context.Context, progress ProgressFunc) (Result, error)

UpdateWithProgress downloads, verifies, and installs the latest release while reporting progress.

Jump to

Keyboard shortcuts

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