Documentation
¶
Overview ¶
Package update replaces the running binary with the latest GitHub release.
Index ¶
Constants ¶
const ( StepCurrent = "current version" StepQuery = "query latest release" StepSelect = "select asset" StepChecksum = "download checksums" StepDownload = "download binary" StepVerify = "verify checksum" StepInstall = "install" StepDone = "done" )
Step names, in the order Run goes through them. Errors from Run name the step that failed ("update failed at <step>: ...").
const BarWidth = 40
BarWidth is the number of cells in a known-length progress bar.
const ChunkSize = 256 << 10
ChunkSize is how many bytes one '#' stands for when the length is unknown.
const DefaultAPIURL = "https://api.github.com/repos/vicgupta/tinyagent/releases/latest"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type JSONReporter ¶ added in v0.11.0
JSONReporter writes each step as a JSONL event {"type":"update.step","step":...,"detail":...} to W, and no progress bar.
func (*JSONReporter) Download ¶ added in v0.11.0
func (r *JSONReporter) Download(string, int64) (io.Writer, func())
func (*JSONReporter) Step ¶ added in v0.11.0
func (r *JSONReporter) Step(step, detail string)
type ProgressBar ¶ added in v0.11.0
ProgressBar draws download progress to W. With Total > 0 it redraws one line, "\r [####....] 42% 1.2 MiB / 2.9 MiB", as bytes arrive; with Total <= 0 it appends one '#' per ChunkSize bytes. Finish ends the line.
func (*ProgressBar) Finish ¶ added in v0.11.0
func (p *ProgressBar) Finish()
Finish ends the progress line.
type Reporter ¶ added in v0.11.0
type Reporter interface {
Step(step, detail string)
Download(name string, total int64) (io.Writer, func())
}
Reporter receives Run's progress. Step is called once per step with a human-readable detail; Download is called before the binary download and returns a writer fed every byte as it arrives (nil for none) and a finish func called once the body is read or fails.
type TextReporter ¶ added in v0.11.0
TextReporter prints one "update: <step>: <detail>" line per step to W. With Bar set (W is a terminal), the download draws a '#' progress bar; otherwise the download prints only plain lines, with no carriage returns.
func (*TextReporter) Download ¶ added in v0.11.0
func (r *TextReporter) Download(name string, total int64) (io.Writer, func())
func (*TextReporter) Step ¶ added in v0.11.0
func (r *TextReporter) Step(step, detail string)