Documentation ¶
Index ¶
Constants ¶
View Source
const DefaultCheckInterval = 24 * time.Hour
DefaultCheckInterval is the minimum time between checks to see if the program is updated.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Metadata ¶
type Metadata struct { // The time the source binary was updated. Updated time.Time // The difference between the update time of the source binary and the binary on disk. Diff time.Duration }
Metadata contains information about the source binary and the binary on disk.
type Updater ¶
type Updater struct { // URL where the binary can be downloaded. BaseURL string // absolute path to the binary to be updated; defaults to the currently executing binary Path string // interval between automatic update checks CheckInterval time.Duration // Function used to output logs if not nil. Logf func(message string, args ...interface{}) // Call the new binary with these arguments to "apply" an update. If it fails, the binary // will not be replaced. ApplyArgs []string }
Updater keeps a Go binary up to date with a version available via HTTP(S). This can be used to implement auto-updating command line tools.
func (*Updater) MaybeCheckForUpdate ¶
MaybeCheckForUpdate checks for an update if it has been long enough since the last check. It returns the metadata or an error if it executes a check. It returns a zero Metadata value if it does not check for an update.
Click to show internal directories.
Click to hide internal directories.