selfupdate

package
v1.0.18 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 16 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 selfupdate replaces a running wowsimforever or wowsimcli with the newest release on GitHub and restarts it.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDevelopmentBuild = errors.New("a development build does not update itself")
	ErrNotWritable      = errors.New("the folder holding the executable is not writable")
)

Functions

func Restarted

func Restarted() bool

Whether this process was started by Restart after an update. A caller skips updating again on startup, so a release stamped with the wrong version cannot restart in a loop.

Types

type Config

type Config struct {
	Name       string              // The binary's name in the release assets and inside their archives, e.g. "wowsimforever".
	Version    string              // The running build's version tag; "" or "development" is a local build.
	Executable string              // The file an update replaces; ForExecutable passes os.Executable().
	Source     goselfupdate.Source // Where releases come from; ForExecutable passes the releases on GitHub.
}

type Release

type Release struct {
	Tag string // The release's tag, e.g. "v0.0.100".
	URL string // The release's page.
	// contains filtered or unexported fields
}

A newer release than the running build.

type Updater

type Updater struct {
	// contains filtered or unexported fields
}

func ForExecutable

func ForExecutable(name, version string) (*Updater, error)

An updater for the running executable, reading the releases of wowsims/forever on GitHub with $GITHUB_TOKEN when it is set.

func New

func New(cfg Config) (*Updater, error)

func (*Updater) Apply

func (u *Updater) Apply(ctx context.Context, release *Release) error

The library's own UpdateTo looks inside the archive for a file named like the executable, which fails when the user renamed it, so the archive is read here by the release name instead.

func (*Updater) CanWrite

func (u *Updater) CanWrite() bool

Whether a file can be created next to the executable, which replacing it needs.

func (*Updater) Check

func (u *Updater) Check(ctx context.Context) (*Release, error)

The newest release when it is strictly newer than the running build, or nil when there is none.

func (*Updater) RemoveOld

func (u *Updater) RemoveOld()

Removes the previous executable an update left behind. Windows cannot delete a running executable, so the update renames it to a hidden .<name>.old, and the process that replaced it may still be exiting: the removal is retried for a few seconds.

func (*Updater) Restart

func (u *Updater) Restart(args []string) error

Starts the executable again with args. On Windows it starts as a child with the same console and this process exits at once, so a shell that started the simulator gets its prompt back; the process must not wait, because a second update renames the executable onto the .old file it would still run from. Returns only on failure.

Jump to

Keyboard shortcuts

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