Documentation
¶
Overview ¶
Package update finds out whether a newer Chapar release is out, and downloads, verifies and installs it where the platform allows.
Index ¶
- Constants
- Variables
- func AssetName(version, goos, goarch string) (string, bool)
- func BrewUpgrade(context.Context, io.Writer) error
- func Cleanup()
- func Install(context.Context, string) error
- func InstalledVersion() string
- func IsRelease(v string) bool
- func Newer(current, latest string) bool
- func ParsePrivateKey(s string) (ed25519.PrivateKey, error)
- func ParsePublicKey(s string) (ed25519.PublicKey, error)
- func Restart() error
- func Sign(key ed25519.PrivateKey, name, sha256Hex string) string
- type Asset
- type Client
- type Method
- type Progress
- type Release
Constants ¶
const LatestURL = "https://api.github.com/repos/chapar-rest/chapar/releases/latest"
LatestURL is the GitHub API endpoint for the newest published release. Drafts and prereleases never show up there.
const SigSuffix = ".sig"
SigSuffix is appended to an asset's name to get its signature asset.
Variables ¶
var ErrUnsupported = errors.New("this copy of Chapar can't update itself")
ErrUnsupported means this copy of Chapar cannot update itself; the user downloads the new version instead.
Functions ¶
func AssetName ¶
AssetName is the release file for the app on goos/goarch, following the artifact pattern in yoga.toml.
func InstalledVersion ¶
func InstalledVersion() string
InstalledVersion is only known for macOS app bundles.
func Newer ¶
Newer reports whether latest is a later version than current. A current version that is not a release (a dev build) is never behind.
func ParsePrivateKey ¶
func ParsePrivateKey(s string) (ed25519.PrivateKey, error)
ParsePrivateKey decodes a base64 ed25519 seed.
func ParsePublicKey ¶
ParsePublicKey decodes a base64 ed25519 public key.
Types ¶
type Asset ¶
type Asset struct {
Name string
URL string // direct download
Size int64
// Digest is GitHub's "sha256:<hex>" for the file, empty on old releases.
Digest string
}
Asset is one file attached to a release.
type Client ¶
Client fetches release info and assets. The zero value uses LatestURL and an HTTP client that honors the proxy environment variables.
type Progress ¶
type Progress func(done, total int64)
Progress reports bytes downloaded so far out of total (0 when unknown).