update

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 18 Imported by: 1 module, 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 update replaces the running git-stack binary with the latest GitHub release.

It talks plain HTTPS to the GitHub releases API and the release assets, so it works without gh being logged in. Assets are the archives goreleaser publishes (git-stack_<ver>_<os>_<arch>.tar.gz plus checksums.txt); the archive is verified against checksums.txt before anything is written.

Index

Constants

View Source
const DefaultRepo = "DomBlack/git-stack"

DefaultRepo is the GitHub repository releases are published from.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	HTTP      *http.Client
	BaseURL   string // GitHub API base, https://api.github.com
	Repo      string // owner/name
	UserAgent string
}

Client fetches releases. The zero value is not usable; use New.

func New

func New(current version.Info) *Client

New returns a client for the public GitHub API.

func (*Client) Latest

func (c *Client) Latest(ctx context.Context) (Release, error)

Latest fetches the newest release.

func (*Client) Run

func (c *Client) Run(ctx context.Context, o Options) (Result, error)

Run compares the running binary with the latest release and, unless told otherwise, downloads and installs it.

type Options

type Options struct {
	// Current is the running binary's version.
	Current version.Info
	// Target is the file to replace, normally os.Executable with symlinks resolved.
	Target string
	// GOOS and GOARCH pick the asset.
	GOOS, GOARCH string
	// Check only reports; nothing is downloaded.
	Check bool
	// Force replaces the binary even when it is up to date, ahead, or a dev build.
	Force bool
}

Options control Run.

type Release

type Release struct {
	Tag    string
	Assets map[string]string // asset name -> download URL
}

Release is a published release and its downloadable assets.

type Result

type Result struct {
	Status  Status
	Current string
	Latest  string
	// DevBuild is true when the running binary is not a release.
	DevBuild bool
	Target   string
}

Result reports the outcome of Run.

type Status

type Status int

Status says what Run did.

const (
	// StatusUpToDate: the binary already is the latest release.
	StatusUpToDate Status = iota
	// StatusAhead: the binary is newer than the latest release.
	StatusAhead
	// StatusAvailable: a release is available but nothing was changed (Check,
	// or a dev build without Force).
	StatusAvailable
	// StatusUpdated: the binary was replaced.
	StatusUpdated
)

Jump to

Keyboard shortcuts

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