selfupdate

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: AGPL-3.0 Imports: 23 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 implements explicit, verified release updates and optional notices.

Index

Constants

View Source
const DefaultInterval = time.Hour
View Source
const MinimumInterval = 15 * time.Minute
View Source
const Repository = "https://github.com/csautter/sailwright"

Variables

This section is empty.

Functions

func Cleanup

func Cleanup(executable string)

Cleanup removes Windows backups on a subsequent invocation. In-use files stay put.

func Compare

func Compare(a, b string) int

Compare compares stable release versions without integer overflow. Invalid versions (such as "dev") sort below every valid version and equal each other.

func Eligible

func Eligible(command, version string, tty bool, getenv func(string) string) bool

func Enabled

func Enabled(s Settings, getenv func(string) string) bool

func Executable

func Executable() (string, error)

func Installation

func Installation(executable, version string) string

Installation classifies the resolved path, including Homebrew's symlink targets.

func Replace

func Replace(items []Replacement) error

Replace stages all verified binaries beside their targets before changing anything. Unix renames each binary atomically. Windows keeps the previous executable as .old. If any rename fails, completed changes are rolled back.

func SaveSettings

func SaveSettings(file string, s Settings) error

func ValidVersion

func ValidVersion(v string) bool

ValidVersion accepts stable release versions only; development builds cannot update.

func ValidateBaseURL

func ValidateBaseURL(raw string) error

ValidateBaseURL limits the release source override to local test fixtures, so a leaked environment variable cannot redirect updates to a remote server.

func Writable

func Writable(executable string) error

Writable probes the directory before making any release requests, without sudo.

Types

type Checker

type Checker struct {
	Releases  Releases
	Settings  Settings
	CacheFile string
	Now       func() time.Time
}

func (Checker) Start

func (c Checker) Start() func() string

Start reserves a short retry window before launching a bounded request. The interval starts only once a request completes, so a command that exits before the response arrives does not suppress checks for a whole interval. Finish waits at most noticeGrace for a pending request; a later result is used on the next run.

type Releases

type Releases struct {
	BaseURL          string // Repository URL; override only for local release fixtures.
	Client           *http.Client
	Version          string
	RequireSignature bool
}

func (Releases) Binary

func (r Releases) Binary(ctx context.Context, tag, name, goos, arch string, checksums []byte) ([]byte, error)

func (Releases) Checksums

func (r Releases) Checksums(ctx context.Context, tag string) (data []byte, signed bool, err error)

Checksums downloads the checksum manifest and verifies its signature whenever cosign is installed. RequireSignature fails closed if cosign is unavailable. signed reports whether the signature was verified.

func (Releases) Latest

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

Latest reads just the redirect, without downloading the release HTML or calling the API.

type Replacement

type Replacement struct {
	Path string
	Data []byte
}

type Settings

type Settings struct {
	Enabled          bool
	Interval         time.Duration
	RequireSignature bool
}

func DefaultSettings

func DefaultSettings() Settings

DefaultSettings are used when no settings file exists or it cannot be used.

func LoadSettings

func LoadSettings(file string) (Settings, error)

LoadSettings always returns usable settings: on error it returns the defaults together with the error, so callers can warn and overwrite a broken file.

func (Settings) MarshalJSON

func (s Settings) MarshalJSON() ([]byte, error)

func (*Settings) UnmarshalJSON

func (s *Settings) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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