Help us shape the future of Go! Take the 2026 Go Developer Survey

selfupdate

package
v0.1.38 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package selfupdate finds newer releases of the modlock command line and installs one over the running executable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Asset

func Asset() string

Asset returns the name of the release file that holds the command line for this computer.

func Check

func Check(ctx context.Context, current string, found func(latest string))

Check calls found with the newest release when it is later than current. It answers at once from the answer cached in the user cache, which holds the newest tag and, as its modification time, when it was learned. When that is older than a day it also asks GitHub in the background and calls found again if the fresh answer is later still. found runs at most twice, on any goroutine, and never after ctx ends. Every failure is dropped: the check must never slow or fail the command that runs it.

func Clean

func Clean()

Clean removes the file an update on Windows moved aside, once the command line that ran from it has exited. It does nothing elsewhere.

func Executable

func Executable() (string, error)

Executable returns the file of the running command line, through any symbolic link that names it.

func Install

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

Install replaces the executable at exe with the command line of the release tagged version. It downloads the new file beside exe, runs it once to check that it starts and names version, and only then renames it into place, so a failed or interrupted update leaves the old command line working. An error wrapping fs.ErrPermission means exe's directory is not writable.

func Latest

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

Latest returns the tag of the newest release.

func Newer

func Newer(latest, current string) bool

Newer reports whether latest is a later release than current.

func Released

func Released(version string) bool

Released reports whether version names a release, such as v0.1.9, rather than a development build.

func Remember

func Remember(latest string)

Remember caches latest as the newest release, learned now.

Types

This section is empty.

Jump to

Keyboard shortcuts

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