{"modulePath":"github.com/hyperhq/hypercli","version":"v1.10.16","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package selfupdate\n\nUpdate protocol:\n\n\tGET hk.heroku.com/hk/linux-amd64.json\n\n\t200 ok\n\t{\n\t    \"Version\": \"2\",\n\t    \"Sha256\": \"...\" // base64\n\t}\n\nthen\n\n\tGET hkpatch.s3.amazonaws.com/hk/1/2/linux-amd64\n\n\t200 ok\n\t[bsdiff data]\n\nor\n\n\tGET hkdist.s3.amazonaws.com/hk/2/linux-amd64.gz\n\n\t200 ok\n\t[gzipped executable data]\n\n## Variables\n\n```go\nvar ErrHashMismatch = errors.New(\"new file hash mismatch after patch\")\n```\n\n## Types\n\n```go\ntype HTTPRequester struct {\n}\n```\nHTTPRequester is the normal requester that is used and does an HTTP to the url location requested to retrieve the specified data.\n\n```go\nfunc (httpRequester *HTTPRequester) Fetch(url string) (io.ReadCloser, error)\n```\nFetch will return an HTTP request to the specified url and return the body of the result. An error will occur for a non 200 status code.\n\n```go\ntype Requester interface {\n\tFetch(url string) (io.ReadCloser, error)\n}\n```\nRequester interface allows developers to customize the method in which requests are made to retrieve the version and binary\n\n```go\ntype Updater struct {\n\tCurrentVersion string    // Currently running version.\n\tApiURL         string    // Base URL for API requests (json files).\n\tCmdName        string    // Command name is appended to the ApiURL like http://apiurl/CmdName/. This represents one binary.\n\tBinURL         string    // Base URL for full binary downloads.\n\tDiffURL        string    // Base URL for diff downloads.\n\tDir            string    // Directory to store selfupdate state.\n\tForceCheck     bool      // Check for update regardless of cktime timestamp\n\tRequester      Requester //Optional parameter to override existing http request handler\n\tInfo           struct {\n\t\tVersion string\n\t\tSha256  []byte\n\t}\n}\n```\nUpdater is the configuration and runtime data for doing an update.\n\nNote that ApiURL, BinURL and DiffURL should have the same value if all files are available at the same location.\n\nExample:\n\n\tupdater := \u0026selfupdate.Updater{\n\t\tCurrentVersion: version,\n\t\tApiURL:         \"http://updates.yourdomain.com/\",\n\t\tBinURL:         \"http://updates.yourdownmain.com/\",\n\t\tDiffURL:        \"http://updates.yourdomain.com/\",\n\t\tDir:            \"update/\",\n\t\tCmdName:        \"myapp\", // app name\n\t}\n\tif updater != nil {\n\t\tgo updater.BackgroundRun()\n\t}\n\n```go\nfunc (u *Updater) BackgroundRun(update bool) error\n```\nBackgroundRun starts the update check and apply cycle.\n\n```go\nfunc (u *Updater) WantUpdate() bool\n```\n\n","path":"github.com/hyperhq/hypercli/pkg/selfupdate","name":"selfupdate","synopsis":"Update protocol: GET hk.heroku.com/hk/linux-amd64.json 200 ok { \"Version\": \"2\", \"Sha256\": \"...\" // base64 } then GET hkpatch.s3.amazonaws.com/hk/1/2/linux-amd64 200 ok [bsdiff data] or GET hkdist.s3.amazonaws.com/hk/2/linux-amd64.gz 200 ok [gzipped executable data]","isRedistributable":true}
