selfupdate

package
v0.1.82 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 16 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 Build added in v0.1.81

func Build(ctx context.Context, exe string, output io.Writer) (string, error)

Build builds the newest commit of the master branch on this computer and replaces the executable at exe with it, writing the tools' output to output. It keeps the source and the build in the user cache, so a later build compiles only what changed, and installs the game server it builds where a session looks for that version's. It returns the version built, which is the one the master channel gives the same commit.

func Check

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

Check calls found with channel's newest build when it should replace current. It answers at once from the answer cached in the user cache, which holds the newest version 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 version, a release or a build of master. 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(channel Channel, latest string)

Remember caches latest as channel's newest build, learned now.

Types

type Channel added in v0.1.81

type Channel string

Channel names the line of builds modlock update follows.

const (
	// Stable follows the releases, such as v0.1.9.
	Stable Channel = "stable"
	// Master follows the master branch: the build of its newest commit.
	Master Channel = "master"
)

func ParseChannel added in v0.1.81

func ParseChannel(name string) (Channel, error)

ParseChannel returns the channel named name.

func (Channel) Latest added in v0.1.81

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

Latest returns the version of the channel's newest build.

func (Channel) News added in v0.1.81

func (c Channel) News(latest, current string) bool

News reports whether latest, the channel's newest build, should replace current. A release replaces only an older release. A build of master replaces any other published version, since master has no order to read from a version. A development build is never replaced.

Jump to

Keyboard shortcuts

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