Documentation
¶
Overview ¶
Package release checks for a newer published release and replaces the running binary with it.
It fails closed on verification. install.sh warns and continues when checksums.txt is missing, because a first install with no binary at all is worse than an unverified one. An update is the opposite case: there is already a working binary on disk, so an unverifiable download has nothing to offer and is refused.
Stdlib only, like the rest of the project. Nothing here needs a dependency.
Index ¶
Constants ¶
const Repo = "AlleyBo55/KiroBuff"
Repo is the upstream project. Kept as a constant rather than a flag: pointing a self-updater at an arbitrary repository is a way to install someone else's binary under this one's name.
Variables ¶
var ErrDevBuild = errors.New("this is a development build, not a released version")
ErrDevBuild means the running binary has no release version to compare against, so "newer" is not a question that can be answered.
var ErrNoAsset = errors.New("no release asset for this platform")
ErrNoAsset means the release exists but carries nothing for this platform.
Functions ¶
func AssetName ¶
AssetName returns the archive filename GoReleaser produces for a platform. It must stay in step with the name_template in .goreleaser.yaml.
func Newer ¶
Newer reports whether latest is a higher version than current.
An unparseable current version returns ErrDevBuild: a locally built binary reports "dev", and treating that as older than everything would let a stray `kirobuff update` overwrite a build someone is actively debugging.
func Replace ¶
Replace overwrites dest with payload.
The new file is written beside the target so the final step is a rename on the same filesystem, which is atomic: an interrupted update leaves either the old binary or the new one, never a half-written file. The old binary is moved aside first because Windows refuses to rename over a running executable.
Types ¶
type Source ¶
type Source struct {
// API is the repository API root, without a trailing slash.
API string
// Downloads is the release-asset root, without a trailing slash.
Downloads string
// Client performs the requests. nil means a client with a sane timeout.
Client *http.Client
}
Source is where releases are read from. The zero value is not useful; call Default. The fields exist so tests can point at a local server instead of GitHub.