selfupdate

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 16 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 selfupdate replaces the running agent2api binary with the latest published release.

It deliberately mirrors scripts/install.sh — same release, same archive names, same checksums.txt — so a machine ends up with exactly the file the installer would have written. One rule is stricter: a checksum that is missing or does not match is fatal here. The installer is creating a file that did not exist and can reasonably warn and continue; update overwrites a binary the user already trusts, so it gets no "skipping verification" path.

Index

Constants

View Source
const (
	// DefaultRepo is the GitHub repository releases are published to.
	DefaultRepo = "Dongss/agent2api"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Current is the version this build reports, e.g. "v0.1.0". An update is
	// skipped when it already equals the latest tag.
	Current string
	// Repo is "owner/name"; defaults to [DefaultRepo].
	Repo string
	// BaseURL overrides the release host. For tests.
	BaseURL string
	// Client overrides the HTTP client. For tests.
	Client *http.Client
	// Dest is the binary to replace. Empty means the running executable.
	Dest string
}

Options configures one update. The zero value updates the running binary from the project's own GitHub releases, which is what the CLI passes.

type Result

type Result struct {
	// From is the version that was installed, To the latest release. They are
	// equal exactly when Updated is false.
	From, To string
	// Path is the binary that was (or would have been) replaced.
	Path string
	// Updated reports whether the binary on disk changed.
	Updated bool
}

Result describes what an update did, including the case where it did nothing because the binary was already current.

func Run

func Run(ctx context.Context, opts Options) (Result, error)

Run updates the binary to the latest release.

Nothing on disk is touched until the download is complete and verified, so a network failure, a bad checksum or a cancelled context all leave the existing binary exactly as it was.

Jump to

Keyboard shortcuts

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