Documentation
¶
Overview ¶
Package update checks GitHub for a newer openapi-generator and replaces this binary with it. Releases publish one bare binary per platform plus a CHECKSUMS.txt; nothing is installed that the checksum file does not cover.
Index ¶
Constants ¶
const Dev = "dev"
Dev is the version a build without -ldflags reports. It is never offered an update, so a working copy is not nagged about the release it is ahead of.
const Repo = "xseman/openapi-generator"
Repo is the GitHub repository releases are published to.
Variables ¶
var API = "https://api.github.com/repos/" + Repo + "/releases/latest"
API is the latest-release endpoint. The tests point it at a local server.
var Path = func() (string, error) { exe, err := os.Executable() if err != nil { return "", err } if p, err := filepath.EvalSymlinks(exe); err == nil { return p, nil } return exe, nil }
Path is this executable with its symlinks resolved: the file an update replaces. It is a variable so a test can aim an install at a scratch file instead of the binary running it.
var Version = Dev
Version is the release this binary was built from, set at link time with `-X github.com/xseman/openapi-generator/internal/update.Version=1.2.3`.
Functions ¶
func Compare ¶
Compare orders two dotted versions as -1, 0 or +1. A pre-release suffix ("1.2.3-rc1") is cut off, and a field that is not a number counts as 0, so Dev sorts below every release.
func Download ¶
func Download(ctx context.Context, rel Release, dir string, progress func(done, total int64)) (string, error)
Download fetches the release binary into dir and returns the path of the file, which is left there only when its SHA-256 matches. progress, when it is not nil, is called as bytes arrive; total is 0 when the server sends no length.
Types ¶
type Release ¶
type Release struct {
Version string `json:"version"`
URL string `json:"url"`
SHA256 string `json:"sha256"`
Notes string `json:"notes,omitempty"`
}
Release is the newest published openapi-generator: its version, where this platform's binary is, and what that binary must hash to.