selfupdate

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 15 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 finds the latest custos release, tells how the running binary was installed, keeps the result of the last release check, and replaces a standalone binary with a checksum-verified release binary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Asset

func Asset() string

Asset is the name of the bare release binary for this platform.

func AssetBase

func AssetBase(version string) string

AssetBase is where the assets of version are downloaded from: $CUSTOS_DOWNLOAD_URL (a mirror URL or a local directory), else the GitHub release.

func Latest

func Latest(ctx context.Context) (string, error)

Latest returns the version (without "v") of the latest release. It reads the redirect of the releases/latest page, which, unlike the GitHub API, has no anonymous rate limit.

func Newer

func Newer(current, latest string) bool

Newer reports whether latest is a later release than current. Either one not being a release version means no.

func Replace

func Replace(ctx context.Context, exe, version string) error

Replace downloads the release binary of version, checks it against the release's SHA256SUMS and puts it in place of exe.

func SaveCheck

func SaveCheck(dir string, c Check) error

SaveCheck records c in dir.

func Valid

func Valid(v string) bool

Valid reports whether v is a release version (X.Y.Z); development builds ("dev") and pre-releases are not.

Types

type Check

type Check struct {
	Latest  string    `json:"latest"`
	Checked time.Time `json:"checked"`
}

Check is the result of the last release check.

func ReadCheck

func ReadCheck(dir string) Check

ReadCheck returns the last check saved in dir, or the zero Check when there is none or it cannot be read.

type Install

type Install struct {
	Method Method
	// Path is the binary itself, symlinks resolved.
	Path string
	// Root is the Composer project requiring custos, when known.
	Root string
}

Install describes the running binary.

func Detect

func Detect(version string) (Install, error)

Detect tells how the binary of the given version was installed. The Composer launcher announces itself with CUSTOS_INSTALL=composer and passes the project root in CUSTOS_COMPOSER_ROOT; Homebrew and launcher downloads are otherwise recognized by where the binary lives.

type Method

type Method int

Method is how the running binary was installed.

const (
	// Standalone is a release binary placed on the PATH by hand.
	Standalone Method = iota
	// Source is a development build.
	Source
	// Homebrew is the janalis/tap/custos cask.
	Homebrew
	// Composer is the binary run by the janalis/custos Composer launcher.
	Composer
)

Jump to

Keyboard shortcuts

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