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 ¶
var ( ErrDevelopmentBuild = errors.New("a development build does not update itself") ErrNotWritable = errors.New("the folder holding the executable is not writable") )
Functions ¶
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 ¶
An updater for the running executable, reading the releases of wowsims/forever on GitHub with $GITHUB_TOKEN when it is set.
func (*Updater) Apply ¶
Downloads the release, checks it against checksums.txt and replaces the executable with it. 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 ¶
Whether a file can be created next to the executable, which replacing it needs.
func (*Updater) Check ¶
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 ¶
Starts the executable again with args (os.Args[1:] keeps the same ones). 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. Elsewhere it replaces this process. Returns only on failure.