Documentation
¶
Overview ¶
Package update provides tooling to auto-update binary releases from GitHub based on the user's current version and operating system.
Example ¶
// update polls(1) from tj/gh-polls on github
p := &update.Project{
Command: "polls",
Owner: "tj",
Repo: "gh-polls",
Version: "0.0.3",
}
// fetch the new releases
releases, err := p.LatestReleases()
if err != nil {
log.Fatalf("error fetching releases: %s", err)
}
// no updates
if len(releases) == 0 {
log.Println("no updates")
return
}
// latest release
latest := releases[0]
// find the asset for this system
a := latest.FindTarball(runtime.GOOS, runtime.GOARCH)
if a == nil {
log.Println("no binary for your system")
return
}
// whitespace
fmt.Println()
path, err := a.DownloadProxy(progress.Reader)
if err != nil {
log.Fatalf("error downloading: %s", err)
}
// replace the previous
if err := p.Install(path); err != nil {
log.Fatalf("error installing: %s", err)
}
fmt.Printf("Updated to %s\n", latest.Version)
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotFound is returned from GetRelease if the release is not found. ErrNotFound = errors.New("release not found") )
Errors.
View Source
var NopProxy = func(size int, r io.ReadCloser) io.ReadCloser {
return r
}
NopProxy does nothing.
Functions ¶
This section is empty.
Types ¶
type Asset ¶
type Asset struct {
Name string // Name of the asset.
Size int // Size of the asset.
URL string // URL of the asset.
Downloads int // Downloads count.
}
Asset represents a project release asset.
type Manager ¶
type Manager struct {
Store // Store for releases such as Github or a custom private store.
Command string // Command is the executable's name.
}
Manager is the update manager.
type Proxy ¶
type Proxy func(int, io.ReadCloser) io.ReadCloser
Proxy is used to proxy a reader, for example using https://github.com/cheggaaa/pb to provide progress updates.
type Release ¶
type Release struct {
Version string // Version is the release version.
Notes string // Notes is the markdown release notes.
URL string // URL is the notes url.
PublishedAt time.Time // PublishedAt is the publish time.
Assets []*Asset // Assets is the release assets.
}
Release represents a project release.
func (*Release) FindTarball ¶
FindTarball returns a tarball matching os and arch, or nil.
Directories
¶
| Path | Synopsis |
|---|---|
|
_example
|
|
|
latest
command
|
|
|
specific
command
|
|
|
Package progress provides a proxy for download progress.
|
Package progress provides a proxy for download progress. |
|
stores
|
|
|
apex
Package apex provides an Apex release store.
|
Package apex provides an Apex release store. |
|
github
Package github provides a GitHub release store.
|
Package github provides a GitHub release store. |
Click to show internal directories.
Click to hide internal directories.