Documentation
¶
Index ¶
- type Release
- type ReleaseAsset
- type Updater
- func (u *Updater) CleanUp(path string)
- func (u *Updater) CurrentVersion() *Version
- func (u *Updater) DownloadAsset(asset *ReleaseAsset) (string, error)
- func (u *Updater) FindLatestRelease() (*Release, error)
- func (u *Updater) GetVersion(path string) (*Version, error)
- func (u *Updater) Replace(path string) error
- type Version
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Release ¶
type Release struct {
URL string `json:"url"`
Assets []*ReleaseAsset `json:"assets"`
Name string `json:"name"`
TagName string `json:"tag_name"`
}
Release is a github release.
func (*Release) FindAssetForSystem ¶
func (r *Release) FindAssetForSystem(os string, arch string) *ReleaseAsset
FindAssetForSystem searches returns the asset for the given OS and arch.
type ReleaseAsset ¶
type ReleaseAsset struct {
URL string `json:"url"`
Name string `json:"name"`
BrowserDownloadURL string `json:"browser_download_url"`
}
ReleaseAsset is an asset of a Release.
type Updater ¶
type Updater struct {
// FetchReleaseFn is used to fetch github release information.
FetchReleaseFn func(httpClient *http.Client, user string, repo string, tag string) (*Release, error)
// DownloadFileFn is used to download a file.
DownloadFileFn func(url string, dest string) error
// ChmodFn is used to change the permissions of a file.
ChmodFn func(name string, mode os.FileMode) error
// ExecuteCmdFn executes the given command and returns the output.
ExecuteCmdFn func(name string, arg ...string) ([]byte, error)
// ExecutableFn is used to return the path of the current executable.
ExecutableFn func() (string, error)
// RenameFn is used to rename a file.
RenameFn func(src string, dst string) error
// RemoveFn is used to remove a file.
RemoveFn func(path string) error
// contains filtered or unexported fields
}
Updater provides functionality that allows you to update a binary from github.
func (*Updater) CleanUp ¶
CleanUp cleans up the given path. This should be deferred once a download has completed.
func (*Updater) CurrentVersion ¶
CurrentVersion returns the current version.
func (*Updater) DownloadAsset ¶
func (u *Updater) DownloadAsset(asset *ReleaseAsset) (string, error)
DownloadAsset downloads and returns a path to the given asset.
func (*Updater) FindLatestRelease ¶
FindLatestRelease returns the latest release on the given repo.
func (*Updater) GetVersion ¶
GetVersion returns the version of the given executable.
Click to show internal directories.
Click to hide internal directories.